Why can't i do something like this in javascript?
var big = { a:1, b:2, c:3, d:big.a }
How can an object's one property access another?
//--------------------------------edited as below ----------------------------------
Thanks for all the answers, now i found another question:
when i do this:
var big = {
a : 1,
b : 2,
c : 3,
d : this.a
}
console.log(big.d);
It's undefined
However, when i do this:
var big = {
a : 1,
b : 2,
c : 3,
d : function(){console.log(this.a)}
}
big.d();
It logs out 1
I wonder what's going on here, is it because it is a function in the second code somehow makes the 'this' accessible?
Thanks.