Javascript expression to define object's property name?
- by Kirzilla
Hello,
I'd like to create this object...
object = {
'object[1][var_name_1]' : 'value1',
'object[1][var_name_2]' : 'value2',
};
I'm trying to it this way, but I'm getting error missing : after property id...
function getPrefix() {
return 'object[1]';
}
object = {
getPrefix() + '[var_name_1]' : 'value1',
getPrefix() + '[var_name_2]' : 'value2',
}
What am I doing wrong? Or maybbe it is impossible to set object property name using js experession?
Thank you