How do I reference the same Object’s properties during its creation? [duplicate]

This is ancient history now, but I just learned about getters and setters, which are perfect for your situation, and I’m sure people looking at this issue could get some value from it..

o = {
  a: { foo: 42 },
  get b() {
    return this.a
    }
  }

console.log(o.b) // => { foo: 42 }

Leave a Comment