看到一个问题,大概是这个样子得。
复制代码 代码如下:
name = 'out of you'
foo = function(){
this.name = 'xxoo';
}
foo.prototype.say = function(){
console.log(this.name);
}
f = new foo();
f.say(); // 这句会输出xxoo
setTimeout(f.say, 500); // 这句会输出out of you
复制代码 代码如下:
setTimeout.call(foo(), f.say, 500)
新闻热点
疑难解答
图片精选