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上調(diào)用的this.sayName().如果它指window對(duì)象上沒(méi)有sayName函數(shù)我還能理解,但是去掉this.sayName()后面的括號(hào)后瀏覽器就沒(méi)出現(xiàn)錯(cuò)誤提醒了。為什么我腦子短路了
為什么this.func不是函數(shù)?(構(gòu)造函數(shù)內(nèi)的方法,在構(gòu)造函數(shù)內(nèi)調(diào)用,提示這個(gè)方法不是函數(shù))
慕哥6287543
2018-09-03 12:15:26