Skip to content

Instantly share code, notes, and snippets.

@laverdet
Created March 29, 2011 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save laverdet/893590 to your computer and use it in GitHub Desktop.
Save laverdet/893590 to your computer and use it in GitHub Desktop.
nextTick will ALWAYS fire before a setTimeout from the same tick
setTimeout(function() {
console.log('timeout');
}, 0);
// simulate extreme cpu load
var d = +new Date;
console.log(new Date);
while (d + 2000 > new Date);
console.log(new Date);
process.nextTick(function() {
console.log('nextTick');
});
Tue, 29 Mar 2011 23:48:59 GMT
Tue, 29 Mar 2011 23:49:01 GMT
nextTick
timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment