Can I add a property dynamically in javascript? -


is okay add properties object @ runtime? seems run okay there issues should aware of?

i'm using 3rd party javascript api has object class, i've instantiated , added own property after instantiation, code below:

for example can this:

var car = function (id, type) {     this.id = id;     this.type = type; };  var mycar = new car(1,"nissan");  // can this: (needswork not property of object car) mycar.needswork = true; 

yea, called object augmentation. key feature in javascript.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -