Async: how it is handled internally in JS (Tasks, Microtasks/Jobs, Queues, Schedule)

I have found this wonderful step-by-step-diagramms in an article from I want to share with you: It also contains an example with event bubbling 🙂

In summary:

  • Tasks execute in order, and the browser may render between them
  • Microtasks execute in order, and are executed:
    • after every callback, as long as no other JavaScript is mid-execution
    • at the end of each task

Closures (in JavaScript)

If you return a function (instead of a value or object), you will have to think about closures. You are not just returning the function definition but also the all the variables in scope at the time of creation of the function! This is called a closure. A read a nice Medium article with some very detailed step-to-step explanation, I’d like to recommend.

Continue reading “Closures (in JavaScript)”