NOTE: Please make sure you have latest version of browsers before running the code sample below because there used to be bug in the browser which has been fixed in the latest version of browsers. Major browser vendors (Chrome, Firefox and Safari) agreed to implement task queue and micro task queue stuff as specified in the standard Spec.
Quiz 1 : codepen example:
https://codepen.io/jitubutwal144/pen/GxEoXR?editors=1011
Quiz 2: codepen example:
https://codepen.io/jitubutwal144/pen/XEgdWP?editors=1011
References:
What the heck is event loop anyway ?
https://www.youtube.com/watch?v=8aGhZQkoFbQ
Jake Archibald: In The Loop - JSConf.Asia 2018
https://www.youtube.com/watch?v=cCOL7MC4Pl0
Event loop explainer - and its pseudo code
https://github.com/atotic/event-loop
Blog: You can find animated execution of the code sample above on the following link
https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
Blog: JavaScript: How is callback execution strategy for promises different than DOM events callback?
https://medium.com/@jitubutwal144/javascript-how-is-callback-execution-strategy-for-promises-different-than-dom-events-callback-73c0e9e203b1
- Twitter: https://twitter.com/@jitubutwal144