Is there any way to get something like the following to work in JavaScript?
var foo = {
a: 5,
b: 6,
c: this.a + this.b // Doesn't work
};
In the current form, this code obviously throws a reference error since this
doesn’t refer to foo
. But is there any way to have values in an object literal’s properties depend on other properties declared earlier?