Here's my code:
var obj = {
x: 25,
y: 24,
z: this.x + this.y,
a: function() {
return this.x + this.y;
}
}
console.log(obj.z) //-> NaN
console.log(obj.a()) //-> 49
I expect console.log(obj.z)
to output what console.log(obja())
outputs. But this is not the case. I suspect that there is a good reason not to assign a value of a property to depend on other properties. If so, why?