25
rated 0 times
[
27]
[
2]
/ answers: 1 / hits: 108135
/ 14 Years ago, wed, june 30, 2010, 12:00:00
Is it at all possible to use variable names in object literal properties for object creation?
Example
function createJSON (propertyName){
return { propertyName : Value};
}
var myObject = createJSON(myProperty);
console.log(myObject.propertyName); // Prints value
console.log(myObject.myProperty); // This property does not exist
More From » properties