Predict the output when process.nextTick is scheduled inside a Promise.then and a promise inside nextTick.
MediumP2Output
What does this code print when run as a CommonJS module with node file.js?
1Promise.resolve().then(() => {2 console.log('then 1');3 process.nextTick(() => console.log('tick inside then'));4});5process.nextTick(() => {6 console.log('tick 1');7 Promise.resolve().then(() => console.log('then inside tick'));8});9Promise.resolve().then(() => console.log('then 2'));10console.log('sync');
Saved automatically
One line per console.log. Arrays as [1, 2, 3], objects as { a: 1 }, an uncaught error as Uncaught TypeError: message (Chrome and Node wording).
Hints
Saved automatically