javascript - SetTimeout issue in Node.js -


i've following code runs fine under chrome (v8) fails inside node:

var id; id = settimeout("timeouthandler()", 10); console.log ('set');  function timeouthandler() {   cleartimeout(id);   console.log ('clear'); } 

chrome output:

set  clear  

nodejs output:

set timers.js:110     first._ontimeout();           ^ typeerror: property '_ontimeout' of object [object object] not function     @ timer.listontimeout [as ontimeout] (timers.js:110:15) 

any ideas why? thanks

unlike in browsers, settimeout in node.js not accept string parameter. must pass function. example:

function timeouthandler() {   cleartimeout(id);   console.log ('clear'); }  var id; id = settimeout(timeouthandler, 10); console.log ('set'); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -