To refer to this.property, there is a getter:
var foo = {
a: 5,
b: 6,
get c() {
return this.a + this.b;
}
}
console.log(foo.c) // 11
however, is it possible to do this during object initialization:
var foo = {
HIDING: 0,
get state() {
return this.HIDING;
}
[this.HIDING]: { x: 0, y: 0 },
}
I expect
foo: {
HIDING: 0,
state: 0,
0: { x: 0, y: 0 }
}
Self-references in object literals / initializers this doesn't answer my question because it doesn't talk about using another property value as property name