About Object's Property Name
How to add a property to an object when the property name come from a var? var obj={}; var propName='realName'; obj.propName; //wrong obj.'realName'; //wrong
Solution 1:
You can use square bracket notation:
var obj = {};
var propName = "realName";
obj[propName] = "foo"; // Same as `obj.realName = "foo";`
Post a Comment for "About Object's Property Name"