what about the promise "then" that prints 'C'? How is guaranteed to run before promise callback that prints 'B'?
Event loop visualiser I think this visualisation of event loop would help us to understand why B always prints before C.
p.then callbacks of B and C are parallel, so B's callback takes precedence as event loop uses queue as a data structure for Task and Job queues.
Execution steps are as follows
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
what about the promise "then" that prints 'C'? How is guaranteed to run before promise callback that prints 'B'?
Event loop visualiser I think this visualisation of event loop would help us to understand why B always prints before C.
p.then callbacks of B and C are parallel, so B's callback takes precedence as event loop uses queue as a data structure for Task and Job queues.
Execution steps are as follows