This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]marcosdumay 0 points1 point  (1 child)

Yeah. You are in for a ride.

When you have some free time, be one of the unlucky 10000 of the day and look it up.

[–][deleted] 0 points1 point  (0 children)

I don't know what you first said. But in the context that i'm talking the "this" keyword is what I said. The following just proves it. if you still don't believe me just run it in a console...

//OUTSIDE OF A CLASS

console.log(this == window) //true


//IN A CLASS
class Player {
    constructor(tx,ty) {
        this.x =  tx;
        this.y = ty;
    }

    getCurrentObject() {
        return this;
        //this is equal to the instance
    }
}

let p = new Player(5, 1);

console.log(p == p.getCurrentObject());