How to reference an object inside itself?
As you can see below I'm creating an unnamed object inside the console.log
console.log({
x: 2,
y: this.x * 2,
});
I'm not assigning it to any variable.
So I want a way to access it's property x
inside itself like calling this.x
.
However the above approach is not working.
I'm getting a NAN
error.
NOTE I don't want it to assign to a variable/ create using a function constructor/ prototype.