Skip to content
UniCircle
EasyConceptualBasics

What a JavaScript engine does

Question JS-BAS-001

What is JavaScript, and what does a JavaScript engine such as V8 or SpiderMonkey actually do when it runs your code?

Show hints
  • Separate the engine (runs the language) from the host (browser or Node) that supplies extra APIs.
Show the explanation

Model answer. JavaScript is a dynamically typed, garbage-collected language with first-class functions. It started in browsers and now also runs on servers (Node.js, Deno, Bun).

A JavaScript engine turns source text into running machine code:

  1. Parse the source into an abstract syntax tree (AST).
  2. Interpret it quickly as bytecode, so code starts running straight away.
  3. Optimise: functions that run often ("hot" code) are compiled just-in-time to fast machine code, based on the types actually seen.
  4. Manage memory: allocate objects and free unreachable ones with a garbage collector.

The engine alone knows nothing about pages or files. The host adds those: a browser adds the DOM, fetch and timers; Node.js adds fs, http and its own event loop. That is why document exists in Chrome but not in Node, even though both use V8.

Original UniCircle question. Last reviewed 22 Oct 2026.