Event Loop (EN)

Concept

Central execution mechanism in JavaScript for asynchronous operations

Architecture

flowchart TD     A[Call Stack] -->|Function is executed| B[Event Loop]     C[Event Queue] -->|Callback is added| B     B -->|Call Stack is empty| D[Callback is moved to Call Stack]     E[Web APIs] -->|Async operation completed| C     F[User inputs] -->|Event triggered| C     G[Network requests] -->|Response received| E     H[Timers] -->|Time elapsed| E 

In Context

  • Typically used together with Callbacks, Promises, and async/await
  • Related to: Single-Threaded Execution, Non-blocking I/O, Asynchronous Programming
  • Example use case: Processing user inputs without blocking the user interface
Quelle: AI Generated