You cannot do this. When you are in the process of constructing an object (what you are actually using with curly curly braces), there is no way to access its properties before creating it.
var test = function () {
var o = {};
o['a'] = 1;
o['b'] = o['a'] + 1;
return o;
};
source
share