node.js: how to use setInterval and clearInterval?

后端 未结 3 1719
我寻月下人不归
我寻月下人不归 2020-12-16 12:00

This is my JS in nodeJS :

function test(a, room, seconds) {
    console.log(a, room, seconds);
}

intervalid = setInterval(test, 1000, \'room\', 20);
console         


        
3条回答
  •  暖寄归人
    2020-12-16 12:34

    This just caught me. Exactly the same scenario, clearInterval simply wasn't working.

    Looking in the console, the result of setInterval was an object, not a number. I was quite confused.

    The solution was to remove this import statement, which had snuck in:

    import { setInterval } from 'timers';

提交回复
热议问题