I am using this syntax to create an object:
Lets say i would like to add a new property, called brand, thats is equal to model. Can anyone please explain why this doesnt work?Code:carObject = { model : "Volvo", color : "blue", outputModel : function() { alert("Modelname is: " + this.model) } }; carObject.outputModel(); // alerts "Modelname is Volvo"
Code:carObject = { model : "Volvo", color : "blue", brand : this.model, outputModel : function() { alert("Modelname is: " + this.brand) } }; carObject.outputModel(); // alerts "Modelname is undefined"





Bookmarks