In the following code how do I get the this
keyword to bind to Square
?
Square.prototype.is = {
king: function () { this.piece === "K" }
queen: function () { this.piece === "Q" }
...
};
I know I can later on use call
/apply
but the whole point was to get from
this.isKing()
to
this.is.king()
making it more readable (also grouping the methods together)
this.is.king.apply(this)
seems like a step backwards.