Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to use variable in js key

ES6 defines ComputedPropertyName
var thetop = "top",
    obj = { [thetop]: 10 };

console.log(obj.top); // -> 10
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #variable #js #key
ADD COMMENT
Topic
Name
2+6 =