this的指向问题
下面有两段简单的代码
function Person(){}
Person.prototype.play1=function(){
}
Person.prototype.play=function(){
setInterval(this.play1.bind(this))
}
我想知道的是当this作为参数使用的时候指向谁?
1. this作为对象的时候//参考上述this.play1....
1. 只是参数的时候//...bind(this)
function f1(){console.log(this)};
setInterval(f1,1000);
f1中的this指向window是因为window对象调用了定时器方法所以是window,还是因为函数f1被window对象调用所以是window