This is how I using Object.defineProperties
to generate an objct:
var obj = {
t3: 3,
t1: Object.defineProperties({}, {
getT3: {
value: function () {
console.log(this.t3);
}
},
t2: {
value: this.t3
},
t3: {
value: 4
}
})
}
Now I want to print the obj.t1.t2
value: console.log(obj.t1.t2)
, but the return result is undefined
But I can using the obj.t1.getT3()
method to obtain the obj.t1.t3
's value;
Why the t3
assignment to t2
doesn't work in Object.defineProperties
?
DEMO is here: http://jsfiddle.net/HrLLQ/