I am aware I can use another object's property as a key to declare a property of the object, like so:
var object1 = {
myAttr: 'myName'
};
var object2 = {};
var object2[object1.myAttr] = 'myValue';
Then we have object2.myName == 'myValue'.
How would I go about doing that directly in the object's declaration? Something like that:
var object1 = {
myAttr: 'myName'
};
var object2 = {
object1.myattr: 'myValue'
};
But that actually works.