This is my JS in nodeJS :
function test(a, room, seconds) {
console.log(a, room, seconds);
}
intervalid = setInterval(test, 1000, 'room', 20);
console.log('intervalid', intervalid);
Which returns me the output:
intervalid Timeout {
_called: false,
_idleTimeout: 1000,
_idlePrev: TimersList {
_idleNext: [Circular],
_idlePrev: [Circular],
_timer: Timer { '0': [Function: listOnTimeout], _list: [Circular] },
_unrefed: false,
msecs: 1000,
nextTick: false
},
_idleNext: TimersList {
_idleNext: [Circular],
_idlePrev: [Circular],
_timer: Timer { '0': [Function: listOnTimeout], _list: [Circular] },
_unrefed: false,
msecs: 1000,
nextTick: false
},
_idleStart: 377,
_onTimeout: [Function: test],
_timerArgs: [ 'room', 20 ],
_repeat: 1000
}
Whereas in simple Javascript it returns a simple INTEGER number
When I attach interval to an existing user object, example :
user.intervalid = setInterval(test, 1000, 'room', 20);
I am not able to clearInterval any more :
clearInterval(user.intervalid); // does not work
See Question&Answers more detail:
os