views:

264

answers:

1

This is probably a no-brainer, but how can I make this happen:

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

Thanks in advance!

+3  A: 

Use array notation instead.

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