此代码不起作用:
var counter = 0;
kick(print);
function kick(f) {
setTimeout(function(){
f(); // problem here;
kick();
}, 500);
}
function print(){
console.log(counter++);
}
浏览器控制台给出以下错误:
Uncaught TypeError: f is not a function
我怎样才能f()在需要的时候正确调用?