Skip to content

Instantly share code, notes, and snippets.

@kessler
Created July 4, 2014 15:00
Show Gist options
  • Save kessler/52c160d1425fa017fc7a to your computer and use it in GitHub Desktop.
Save kessler/52c160d1425fa017fc7a to your computer and use it in GitHub Desktop.
simple node.js timers examples
setTimeout(function() {
console.log('queue a print AFTER a second')
}, 1000)
setInterval(function() {
console.log('queue a print EVERY second')
}, 1000)
setImmediate(function() {
console.log('queue a print in the next event loop tick but after IO tasks are done')
})
process.nextTick(function() {
console.log('queue a print at the head of the event loop queue')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment