Why the output result is "1, 2, 3, 4", not "1,4,2,3"?
If you have a answer, pls give a separate answer below, not a comment, explaining which run of the JavaScript event loop do which thing is appreciated,such as:
(1)..
(2)..
(3)..
Thanks!
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
wait(0).then(() => console.log(4));
Promise.resolve().then(() => console.log(2)).then(() => console.log(3));
console.log(1); // 1, 2, 3, 4