I have this
oArray = {};
aProperty = "Property1";
aValue = "Value1";
Is there any way I can use aProperty value as a object name in the array? This is the desired result:
oArray = {
Property1: "Value1"
};
Thanks in advance and regards
I have this
oArray = {};
aProperty = "Property1";
aValue = "Value1";
Is there any way I can use aProperty value as a object name in the array? This is the desired result:
oArray = {
Property1: "Value1"
};
Thanks in advance and regards
It is as simple as below.
var oArray = {};
var aProperty = "Property1";
var aValue = "Value1";
oArray[aProperty] = aValue;
console.log(oArray)
Yes like this:
aProperty = "Property1";
aValue = "Value1";
oArray = {[aProperty]: aValue};