js object key from string code example
Example 1: js get object keys
myObject = {
"key": "value"
}
Object.keys(myObject); // get array of keys
Example 2: javascript create object key from variable
//For ES6 and Babel
{
[yourKeyVariable]: "yourValue",
}
// ES5 Alternative
// Create the object first, then use [] to set your variable as a key
var yourObject = {};
yourObject[yourKeyVariable] = "yourValue";