๐—๐—ฆ ๐—ฅ๐˜‚๐—ป๐˜๐—ถ๐—บ๐—ฒ ๐—˜๐˜…๐—ฝ๐—น๐—ฎ๐—ถ๐—ป๐—ฒ๐—ฑ

JavaScript uses JIT compilation. It works in steps.

JS is single threaded. It runs one instruction at a time on one call stack. It has no parallel execution.

The engine creates an Execution Context for your code.

Execution has two phases.

  1. Memory Creation. The engine stores variables.
  2. Code Execution. The engine runs code line by line.

The call stack uses LIFO. Last In, First Out. If you run an infinite loop, your browser freezes. The stack never empties.

Hoisting moves declarations to the top.

JS does not handle timers or network calls. The host environment does this. The browser or Node.js manages these tasks.

The Event Loop handles callbacks.

The loop runs all microtasks first. Then it runs one macrotask.

Async and await suspend functions. Code after await becomes a microtask.

Source: https://dev.to/dhanushsgowda/your-last-min-js-revision-part-1-the-runtime-30di