js variable for key obj

JavaScript
//You need to make the object first, then use [] to set it.

var key = "happyCount";
var obj = {};
obj[key] = someValueArray;
myArray.push(obj);//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";{
    [yourKeyVariable]: someValueArray,
}  

Source

Also in JavaScript: