What Is JavaScript and How It Differs From ECMAScript
ECMAScript is the language specification, and JavaScript is that language plus what a host adds, like the DOM or Node.js modules. See what belongs to which.

A new developer asks whether setTimeout is part of JavaScript, and gets two correct answers that contradict each other. Yes, because you write it in JavaScript files and it runs wherever JavaScript runs. No, because the language specification never mentions it, and it comes from the environment that hosts the engine. Both are true, and understanding the split removes a large amount of confusion about why code works in a browser and not in Node.js, why document is undefined on a server and why a feature available in one runtime is missing in another. This post defines the terms, separates the layers with a runnable check on Node.js 24, shows what each layer contributes, and ends with the questions to ask when something behaves differently between environments. The engines themselves are compared in the post on JavaScript engines, and the committee that evolves the language is in the post on TC39.
The names
Four terms are used interchangeably and mean different things.
| Term | What it is | Example |
|---|---|---|
| ECMAScript | The language specification, ECMA-262 | Array.prototype.map, class, async and await |
| JavaScript | The language as people write and run it, plus host features | Everything in a typical script |
| Engine | The program that parses and runs the language | V8, SpiderMonkey, JavaScriptCore |
| Runtime or host | An engine plus APIs and an event loop | A browser, Node.js, Deno, Bun |
The name JavaScript is a trademark that Oracle holds, which is why the standard uses ECMAScript, after the organization that publishes it. In practice, the two names mean the same language, and the distinction matters when you want to know who defines a feature. "JavaScript" has nothing to do with Java beyond a marketing decision in 1995, and the two languages share only a few syntax habits.
The language itself is defined in an annual document, the edition, which standards people write as ES2015, ES2025 and so on. Each edition adds features that engines then implement, as covered in the posts on ES2024, ES2025 and ES2026.
What the specification defines
The specification covers the grammar, the types, the built-in objects and the way code executes. It does not cover input and output, timers, the network, the file system, the screen or any way to load a file.
const fromTheLanguage = [
typeof Array,
typeof Map,
typeof Promise,
typeof JSON,
typeof Math,
typeof Intl,
typeof Symbol,
typeof Proxy,
typeof Reflect,
typeof globalThis,
];
console.log(fromTheLanguage.every((type) => type !== "undefined"));
const [a, b] = [1, 2];
const doubled = [a, b].map((n) => n * 2);
console.log(doubled, JSON.stringify({ ok: true }), Math.max(...doubled));
class Greeter {
#name = "world";
greet() {
return `hello ${this.#name}`;
}
}
console.log(new Greeter().greet());
console.log(await Promise.resolve("async works"));true
[ 2, 4 ] {"ok":true} 4
hello world
async worksEverything in that snippet is ECMAScript. It runs the same way in any conforming engine, in any host, because the specification says exactly what each construct does. Not one line of it reads a file, shows a window or waits on a timer.
What the host adds
Everything else comes from the environment. A browser provides the DOM, fetch, localStorage, alert and window. Node.js provides process, Buffer, require and the node: modules. Both provide setTimeout and console, which look like language features and are not.
const hostFeatures = {
setTimeout: typeof setTimeout,
setInterval: typeof setInterval,
console: typeof console,
fetch: typeof fetch,
structuredClone: typeof structuredClone,
URL: typeof URL,
TextEncoder: typeof TextEncoder,
process: typeof process,
Buffer: typeof Buffer,
document: typeof document,
window: typeof window,
localStorage: typeof localStorage,
alert: typeof alert,
require: typeof require,
};
for (const [name, type] of Object.entries(hostFeatures)) {
console.log(name.padEnd(16), type);
}setTimeout function
setInterval function
console object
fetch function
structuredClone function
URL function
TextEncoder function
process object
Buffer function
document undefined
window undefined
localStorage undefined
alert undefined
require undefinedIn Node.js, setTimeout, console, fetch, URL, process and Buffer exist, and document, window, localStorage and alert do not. The require function is undefined because this file is an ES module: CommonJS is a Node.js convention and not part of the language. Several of these, fetch, URL and TextEncoder, are defined by web standards bodies such as WHATWG and implemented by both browsers and Node.js, so they work in both. setTimeout is defined by the HTML standard for browsers, and Node.js implements its own version with different behavior, which is why a timer returns a number in a browser and an object in Node.js.
| Feature | Defined by | Works in |
|---|---|---|
Array, Promise, Map, class | ECMAScript (TC39) | Every engine |
Intl | ECMA-402 (TC39) | Every engine with locale data |
fetch, URL, TextEncoder, AbortController | WHATWG | Browsers, Node.js, Deno, Bun |
document, window, localStorage | HTML and DOM standards | Browsers |
fs, path, process, Buffer | Node.js | Node.js, with partial support elsewhere |
require, module.exports | CommonJS, a Node.js convention | Node.js and bundlers |
Why the split causes bugs
The distinction explains most "works on my machine" problems. Code that touches document or window fails with a ReferenceError on a server, as covered in the post on globalThis. Code that imports node:fs fails in a browser. Code that depends on a recent language feature fails in a runtime whose engine is older, and code that depends on a recent web API fails in a browser that has not shipped it.
function describeEnvironment() {
const language = typeof Array.prototype.at === "function" ? "modern" : "old";
const hasDom = typeof document !== "undefined";
const hasNode = typeof process !== "undefined" && Boolean(process.versions?.node);
const hasFetch = typeof fetch === "function";
return { language, hasDom, hasNode, hasFetch };
}
console.log(describeEnvironment());
try {
console.log(document.title);
} catch (error) {
console.log(error.name + ": " + error.message);
}
try {
const { readFileSync } = await import("node:fs");
console.log(typeof readFileSync);
} catch (error) {
console.log(error.name);
}{ language: 'modern', hasDom: false, hasNode: true, hasFetch: true }
ReferenceError: document is not defined
functionThe check separated the layers: the language feature was present, the DOM was not, Node.js was, and fetch was available because the runtime implements the web standard. The document access failed with a ReferenceError, the message a browser-only program shows on the server. The same error in a test runner usually means that a test needs a DOM environment, and the fix is to configure one and not to change the code.
Layers in a typical program
A running program has five layers, and it helps to name which one you are in. Your code sits on libraries, which sit on the host's APIs, which sit on the engine's built-ins, which are defined by the language. A bug in your code is rarely a bug in a lower layer, and a surprising behavior is often the difference between two hosts.
const layers = [
["your code", "const total = items.map(price).reduce(add, 0)"],
["library", "import { z } from 'zod'"],
["host API", "await fetch(url), setTimeout(fn, 10)"],
["language built-ins", "Array.prototype.map, Promise, JSON"],
["engine", "parses, compiles, runs, collects garbage"],
];
for (const [layer, example] of layers) {
console.log(layer.padEnd(20), example);
}
console.log(typeof process.versions.v8, typeof process.versions.node);your code const total = items.map(price).reduce(add, 0)
library import { z } from 'zod'
host API await fetch(url), setTimeout(fn, 10)
language built-ins Array.prototype.map, Promise, JSON
engine parses, compiles, runs, collects garbage
string stringThe last line prints the types of the engine and runtime version strings that Node.js exposes. The engine is V8, and the runtime is Node.js, and they have separate version numbers: upgrading Node.js changes the V8 version and so the set of language features, and upgrading a browser does the same.
Timers and the event loop
The most visible host feature is the one that gives JavaScript its concurrency. The language has promises and async functions, which describe sequencing, and the event loop that runs callbacks and timers is provided by the host. The ECMAScript specification defines the job queue for promises, and the host defines tasks, timers and input and output. That is why a promise callback always runs before a timer, and the order of two timers can differ between hosts. The post on how JavaScript runs covers the machinery.
const order = [];
setTimeout(() => order.push("timer"), 0);
Promise.resolve().then(() => order.push("promise"));
queueMicrotask(() => order.push("microtask"));
order.push("sync");
await new Promise((resolve) => setTimeout(resolve, 10));
console.log(order);[ 'sync', 'promise', 'microtask', 'timer' ]Synchronous code ran first, then the promise and microtask jobs, then the timer. The first two orderings are guaranteed by the language and the third by the host's event loop design, and both hold in browsers and Node.js.
Questions to ask when behavior differs
When code works in one place and not another, four questions locate the cause. Is the thing a language feature or a host API? If it is a host API, does the other environment define it, and under the same name? If it is a language feature, which engine version is running, and has that version shipped it? And if both exist, do they differ in behavior, as timers, console output and error messages do? The answers point to different fixes: a polyfill, a guard, an environment setting, a compiler or an upgrade.
Where the distinction stops
For daily work, you do not need to think about it: you write JavaScript, and the pieces work together. It matters at the edges: when you move code between a browser and a server, when you read a specification to settle a question, when you file a bug against the right project, and when you decide whether a feature is safe to use. A question about Array behavior goes to the ECMAScript specification, a question about fetch to the Fetch standard, and a question about fs to the Node.js documentation.
The language is defined in ECMA-262, and MDN's pages on JavaScript and on what JavaScript is describe the language and its host environments.


