This first guarantee by MDN does not make sense to me. Can someone explain it using code?
Callbacks will never be called before the completion of the current run of the JavaScript event loop.
This first guarantee by MDN does not make sense to me. Can someone explain it using code?
Callbacks will never be called before the completion of the current run of the JavaScript event loop.
Promise.resolve(2).then(console.log);
console.log(1);
Will always log 1, then 2.
You can resolve the promise now, somewhen or never. But the .then
callbacks will always run after the synchronous code finished.