Skip to content

runtime

A runtime is the software environment that runs JavaScript programs, pairing a JavaScript engine that executes the language with host APIs that let code reach timers, the network, files, or a web page.

The ECMAScript specification defines only the language, including built-in objects such as Array and Promise. It has no provisions for input or output, so the runtime supplies them. The specification calls this supplier the host environment, which is where the name host APIs comes from. Each runtime also creates the global object behind globalThis and drives the event loop that schedules asynchronous callbacks.

Web browsers are runtimes that pair an engine, such as V8, SpiderMonkey, or JavaScriptCore, with web APIs and the DOM. Node.js, Deno, and Bun are server-side runtimes that add APIs for files, processes, and network servers.

Some host APIs, such as fetch() and setTimeout(), exist in browsers and server runtimes alike. Ecma’s TC55 committee lists that shared set in its Minimum Common Web API standard. Beyond it, each runtime decides which globals exist and how they behave, so code written in the same language can still fail when it moves to another runtime.

Each part of a runtime contributes its own set of globals:

A JavaScript runtime pairs an engine with Array and Promise and host APIs, some shared like fetch() and some runtime specific.
What the Engine and the Host Each Provide

Example

Say a utility module is shared between a web page and a Node.js server, and a code review needs to sort the globals it touches into language features and runtime features. The Node.js REPL shows which ones this runtime provides:

Language: JavaScript
> typeof Array
'function'
> typeof Promise
'function'

> typeof fetch
'function'
> typeof setTimeout
'function'

> typeof process
'object'
> typeof document
'undefined'

Array and Promise belong to ECMAScript, so every runtime has them. fetch() and setTimeout() come from the runtime, and both browsers and Node.js provide them. The process object is a Node.js API, and document exists only in browsers, so the shared module can’t rely on either one.

A host API that both runtimes provide can still behave differently. Say the module stores the ID that setTimeout() returns:

Language: JavaScript
> const timer = setTimeout(() => {}, 1000);
undefined
> typeof timer
'object'

> clearTimeout(timer)
undefined

Node.js returns a Timeout object, while browsers return a positive integer, as the HTML Standard defines. A check such as typeof timer === "number" passes in a browser and fails in Node.js.

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Nov. 20, 2026