Consider:
var s1 = {
a: 1,
b: s1.a
};
alert(s1.b); // Uncaught TypeError: Cannot read property 'a' of undefined
Can anyone shed light on the inner workings of JavaScript engines to why this is the case?
Currently I'm forced to use:
var s2 = {
a: {
a: 1
},
b: {
a: function () { return s2.a.a}
}
};
alert(s2.b.a()); // 1