I want to use object's field's value while creating another object using literal notation:
var T = {
fieldName : 'testField'
};
/*
// Doesn't work.
var test = {
T.fieldName : 'value'
};
*/
// Does work.
var test = [];
test[T.fieldName] = 'value';
alert(test.testField); // test
But it doesn't work.
Is there a way to solve this issue or using square brackets is the only way out?
Upd.: Removed non-working code.