0
왜이 기능이 작동하지 않는지 이해할 수 없으며 foreach 메서드로 전달되었습니다.Javascript 중첩 함수가 작동하지 않습니다.
var methods = {
foreach: function(f){
for(var i = 0; i <= this.x; i++){
f(i);
}
}
};
function test(x) {
var t = Object.create(methods);
t.x = x;
return t;
};
var t = test(10);
console.log(t.x); //10
t.foreach(console.log()); //Uncaught TypeError: undefined is not a function
Thx!
t.foreach (CONSOLE.LOG를); // 잡히지 않은 TypeError : 잘못된 호출 –
t.foreach (function (x) {console.log (x)}); // 1 2 3 ... Thx! –
모두 감사합니다! David Flanagan의 저서에서 본 잘못된 예 : Javascript Pocket reference 3 (136 페이지) 오류가있을 수 있다고 생각하지 않았습니다. –