가 발생합니다 :이유는이 객체이지만 직접 호출은 다음과 같이 오류
function Person() {
this.name = "john";
this.getName = function() {
return this.name;
};
}
var me = new Person();
왜하고자했다 절차 :
setTimeout(function(){alert(me.getName())}, 3000);
반환 john
동안 진행 :
setTimeout(me.getName(), 3000);
는 만들
Uncaught TypeError: Object [object DOMWindow] has no method 'getName'
이것은 귀하의 코드가 될 수 없습니다. 나는'setTimeout (me.getName(), 3000); 라인을 가정하고있다.'var me = new Person();'라인을 직접 진행하지는 않는다. 게다가, 당신은'setTimeout (me.getName, 3000);'(괄호 안 함) – rgthree
@rgthree "(괄호 안 함)"- 굉장합니다. – benekastah