任何人都可以解释为什么setInterval在原型中不起作用? 我正在使用Node v4.8.2
function timers(){
console.log("new timer");
}
timers.prototype.start = function(){
console.log("starting timer with interval: 1000");
setInterval(function(){console.log("aa");}, 1000);
}
timer = new timers();
timer.start();
while (true) {
}
输出仅为:
new timer
starting timer with interval: 1000