1//You need to make the object first, then use [] to set it.
2
3var key = "happyCount";
4var obj = {};
5obj[key] = someValueArray;
6myArray.push(obj);
1//For ES6 and Babel
2{
3 [yourKeyVariable]: "yourValue",
4}
5
6// ES5 Alternative
7// Create the object first, then use [] to set your variable as a key
8var yourObject = {};
9
10yourObject[yourKeyVariable] = "yourValue";