I have code like this.
var key = \"anything\"; var object = { key: \"key attribute\" };
I want to know if there is a way to rep
On modern Javascript (ECMAScript 6) you can sorround the variable with square brackets:
var key = "anything"; var json = { [key]: "key attribute" };