You would have to do
myPlayer.onPlay(
function() {
console.log(this);
}.bind(myPlayer)
);
Since you haven't provided what .onPlay
will return, I don't think it would return an object with a bind
method. So you have to use bind
on the function itself. You can't use this
in the bind if you want it to be the myPlayer
, because in your current call scope this
doesn't mean something. It can mean something, but it most likely won't be the player, or else you would have done this.onPlay
. You have to bind myPlayer
with bind
, not this
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…