Learn Simpli

Free Online Tutorial For Programmers, Contains a Solution For Question in Programming. Quizzes and Practice / Company / Test interview Questions.

Concurrency model & event loop in Javascript

Key points
  1. The event loop is responsible for
  2. executing the code
  3. collecting and processing events
  4. and executing queued sub-tasks
JS Runtime Concepts
  1. The following sections explain a theoretical model
  2. Modern JavaScript engines implement and heavily optimize the described semantics
Call Stack:
  1. Where the actual code is executed
Heap:
  1. Where objects are stored
Web APIs:
  1. Apis provided to the engine
  2. Example: DOM, Timers, fetch Apis
Callback Queue:
  1. Ready to be executed callback functions