Skip to content

Instantly share code, notes, and snippets.

@szanata
Created March 9, 2018 01:54
Show Gist options
  • Save szanata/2901bd847aa462994688a604554b1df3 to your computer and use it in GitHub Desktop.
Save szanata/2901bd847aa462994688a604554b1df3 to your computer and use it in GitHub Desktop.
JS: Which is faster?
p = new Promise((r) => {r()});
setImmediate(console.log, 'I1')
process.nextTick(() =>console.log('T1'));
p.then(() => console.log('P1'));
process.nextTick(() =>console.log('T2'));
// Output:
// T1
// T2
// P1
// I1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment