Create object in javascript using JSON
Uncategorized
Add comments
May 042009
Here’s how we create javascript object using Javascript Object Notation (JSON). After the code below is executed, it would show alert windows with text “Borey Lim”
//script to demonstrate creating object in javascript using JSON
var objectDemo = {
firstName: "",
lastName: "",
displayName : function(){
alert(this.firstName + " " + this.lastName);
}
}
objectDemo.firstName = "Borey";
objectDemo.lastName = "Lim";
objectDemo.displayName();