In the following code, the function MakeNode() returns a node, containing the arguments provided to MakeNode(). Within the node, there is a function, an arrow function that requires one of the variables of the node.
I have read the ES6 js doc regarding this. and scopes. Still can't find how my function can access the variable from its own object.
I Have tried accessing it these ways:
this.x
this.X
x
X
n.x
n.X
No success. Actual code:
    function MakeNode(x, y) {
      let n =
      {
        Parent: null,
        X: x,
        Y: y,
        PrintXY: () => {
          console.log("X, Y =", x, y);
        }
      }
      return n;
    }
    
    //further, when called:
    var aNode = MakeNode(10, 20);
    aNode.PrintXY();I expect the print statement to be
X, Y = 10 20
But i get:
X, Y = undefined undefined
I also get the following error, no matter what way i try to access it:
TypeError: Cannot read property 'X' of undefined
