Possible Duplicate:
Self-references in object literal declarations
Is there any way access the value of a property name in the same object literal? Something like this:
myFunction.init({
varOne: 'something',
varTwo: this.varOne + 'something else'
})
varTwo
in the original question will always update whenvarOne
is changed with the getter approach. That is different from what I would expect the behavior to be in the question (assuming it was even possible). If the code in the question actually worked I would expect it to initializevarTwo
withvarOne
once and not changevarTwo
ifvarOne
is changed in the future. – Croat