Dynamic object property names?

How can I make this happen:

var name = otherObject.name; //"string"
var o = { 
            name : otherObject
        };
alert(o["string"].name);

Solution 1:

Use bracket notation instead.

var name = otherObject.name;
var o = {};
o[name] = otherObject;

Or, in modern JavaScript:

var o = {
  [name]: otherObject,
};