I am trying to make an object which has one key name taken from a variable.
var key="KeyName"
var obj={
key:"value"
}
When I want to access the "KeyName" key,I can't because I have just created a key with the name "key" not "KeyName". I found a soution here :
JavaScript set object key by variable
var key="KeyName"
var obj={
[key]:"value"
}
But it doesn't work. What to do?