How else can the JavaScript code below be written using Node.Js to produce the same output?
Anónimo
console.log("first"); setTimeout(function() { console.log("second"); }, 0); console.log("third"); Output: first third second In Node.js version 0.10 or higher, setImmediate(fn) will be used in place of setTimeout(fn,0) since it is faster. As such, the code can be written as follows: console.log("first"); setImmediate(function(){ console.log("second"); }); console.log("third");