Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 663 Bytes

what_is_an_event_loop.md

File metadata and controls

18 lines (11 loc) · 663 Bytes

What is an event loop?

The event loop is a fundamental concept in JavaScript's concurrency model. It is responsible for executing code, handling events, and executing queued messages (tasks). The event loop continuously checks the call stack and event queue, ensuring that asynchronous tasks are executed when the call stack is empty.

Example:

console.log('Start');
setTimeout(() => console.log('Timeout'), 0);
console.log('End');
// Output: 'Start', 'End', 'Timeout'

Tags: basic, JavaScript, concurrency model