function Bird(name){ this.name = name; this.sayName = function(){ console.log('hello '+this.name +' guys');
}
setTimeout(function(){ this.sayName();
},1000);
}var a = new Bird();
a.sayName();Uncaught TypeError: this.sayName is not a function
我指setTimeout上调用的this.sayName().
如果它指window对象上没有sayName函数我还能理解,但是去掉this.sayName()后面的括号后浏览器就没出现错误提醒了。为什么
我脑子短路了
慕哥6287543
SMILET
随时随地看视频慕课网APP
相关分类