What is a runtime — and why console.log is not part of JavaScript

Here's a surprising thing: console.log is not JavaScript. It's not in the language standard. Open the ECMAScript specification — you'll find variables, loops, functions. But the most famous command of all isn't there. It comes from the runtime — the environment that executes your code. Once you see this, half of the "weird" errors stop being weird.
What a runtime is, in plain words
A programming language is grammar. The rules code is written by. On its own, code is just text. Like sheet music: silent on paper.
A runtime is what executes that text. The orchestra for the notes. The player piano for the punched roll. It reads your code and turns it into actions.
And here's the key part. The language can only "think": variables, conditions, loops, arithmetic. Any action outward — printing text, reading a file, sending a request, setting a timer — is handed to your code by the runtime. No environment, no hands.
console.log, fetch, setTimeout — those are hands, not language. That's why they're not in the standard.
One language — different hands
JavaScript lives in at least two environments, and they are two different worlds.
- The browser. There's a page and the DOM — you can change buttons and text. There's
localStorage. But you can't read files from disk: the browser is a security cage. - Node.js. You can read files and start a server. But there's no
document— there's no page.
Hence the classic errors. "document is not defined" — you ran browser code in Node. "require is not defined" — the other way around. The code is fine. The environment is wrong.
Try it yourself in a minute
This is easy to touch with your own hands.
- Open the browser console (F12 → Console) and type
process.version. You'll get an error:processis a Node hand — the browser doesn't have it. - Now open a terminal, type
node, and inside it —document. Another error: the DOM is a browser hand.
One language. Two environments. Two different sets of abilities — you just saw the boundary between them.
Why this matters to you
You read errors correctly. When you see "fetch is not defined", don't rush to rewrite the code. First ask: where am I running it? In Node, fetch only arrived in version 18. The same code fails on old Node and works on new Node. The code didn't change — the environment did.
You understand what you're choosing. "Run it in the browser or on a server" isn't about location. It's about abilities: access to files, to secrets, to other people's APIs without CORS restrictions.
You stop confusing language and platform. You learn JavaScript once. After that, you just learn which hands each environment provides.
Where you'll meet the word
- Node.js, Deno, Bun — three different runtimes for the same JavaScript, each with a slightly different set of hands.
- "Runtime error" — an error during execution. Typos are caught before the program starts; these errors surface on live data.
- Serverless platforms ask at deploy time: "pick a runtime — Node 22 or Python 3.12". That's literally "which environment should we serve you".
- Python — same story: the Python interpreter is its runtime. "My .py file won't run" almost always means "the environment isn't installed".
Why AI code "worked for it" but fails for you
A special case that drives beginners mad. You ask an AI to write a script — it hands you code that fails with "X is not defined". The AI didn't lie: the code is correct. But the model wrote it for one environment, and you're running it in another.
Typical scenarios:
- the AI gave you a Node script that reads files, and you pasted it into the browser console;
- the AI used a fresh runtime command, and your Node is three years old;
- the AI mixed
requireandimport— two module styles the environment won't allow together by default.
The cure is one sentence: tell the AI where the code will live. "Write a script for Node 22" and "write code for the browser" are two different tasks. One phrase in the prompt removes a whole class of errors.
Are a runtime and an engine the same thing?
Almost, but no. The engine (V8, for example) executes the language itself — loops and functions. The runtime is the engine plus the hands around it: files, network, timers. Chrome and Node share the same engine but have different runtimes.
Why is it called a "runtime error"?
Because it happened while the program was running, not while the code was being read. A typo shows up before launch. Division by zero shows up only when live data arrives.
How do I check my environment's version?
Type node --version in the terminal. If AI gave you code with a "new" command and it fails — check the environment version first, before hunting for a bug in the code.
The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.





