ES2015 introduces Promise API as a replacement for callbacks. There are a few things that you may not know.
Promise and the Event Loop
Consider the following async code.
setTimeout(someFunc, 1000);
setTimeout
function waits for one second and then places the function someFunc
at the end of the event loop. All other functions in event loop are processed before someFunc
is taken up for processing.…