Create object in javascript using JSON
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();
Filed under Javascript. Tags: Javascript
0 Comments.