Is it possible, for the push operation, to use the value of a variable and not the name of the variable, as the attribute name in the object?
Example:
for (i=1; i<=5; i++)
{
msg.options.push({i:i});
}
This create the following objects in the msg.options:
msg.options : array[5]
array[5]
0: object
i: 1
1: object
i: 2
2: object
i: 3
3: object
i: 4
4: object
i: 5
Here, it always pushes a new attribute "i", with the current value of "i".
But I don't want all objects to be called "i", I want them to be called as the value of the variable "i".
Example:
msg.options : array[5]
array[5]
0: object
1: 1
...
Any ideas?