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
Post a Comment