Technology  /  JavaScript

๐ŸŸจ JavaScript 15 guides ยท updated 2026

Closures, the event loop, promises, and modern ES syntax โ€” the language of the web explained the way it actually behaves at runtime.

How JavaScript Actually Runs: Engines, Runtimes, and the Languageโ€™s Real Story

JavaScript is the most-deployed programming language in history โ€” it runs on effectively every phone, laptop, and server-adjacent surface on Earth โ€” and itโ€™s also the language most people learn backwards. They start with document.getElementById, absorb a pile of framework habits, and never form a model of whatโ€™s actually executing their code. Then the weird parts of JS (and there are weird parts) feel like random hazing instead of explainable history.

This guide is the missing first chapter: where JavaScript came from, what an engine and a runtime actually are, how your code gets executed, and why the language behaves the way it does. Everything else in this series builds on this foundation.


Ten Days in 1995: The History That Explains the Quirks

JavaScript was created by Brendan Eich at Netscape in ten days in May 1995. Thatโ€™s not an exaggeration for effect โ€” itโ€™s the documented timeline, and it explains more about the language than any other single fact.

Netscape wanted a lightweight scripting language for web pages โ€” something designers could sprinkle into HTML, forgiving of errors, requiring no compiler. Eich originally wanted to build something Scheme-like; management wanted it to โ€œlook like Javaโ€ for marketing reasons (Java was the hot new thing). The name โ€œJavaScriptโ€ was pure marketing โ€” Java and JavaScript are unrelated languages that share four letters and nothing else of consequence.

The ten-day birth left artifacts you still live with:

In 1997, the language was standardized as ECMAScript (Netscape submitted it to the Ecma standards body; โ€œJavaScriptโ€ was trademark-encumbered). Thatโ€™s why you see โ€œES6โ€, โ€œES2015โ€, โ€œES2023โ€ โ€” versions of the ECMAScript specification. The transformative release was ES6/ES2015, which added let/const, classes, modules, arrow functions, promises, and destructuring โ€” effectively the modern language. Since then, a new spec lands every June, and the language you should learn (and this series teaches) is the post-2015 one.

The other historical constraint that shapes everything: โ€œdonโ€™t break the web.โ€ Every quirk shipped in 1995 must work forever, because billions of pages depend on old behavior. JavaScript evolves strictly by addition. Thatโ€™s why old bad features (like var, or ==) still exist alongside their replacements (let/const, ===) โ€” and why learning JS well is partly learning which half of the language to use.


Engine vs. Runtime: The Distinction That Unconfuses Everything

When people say โ€œJavaScript runs in the browser,โ€ theyโ€™re blurring two layers that are worth separating.

The engine executes the language itself โ€” parsing your source, compiling it, running it, managing memory. The major engines:

The runtime wraps an engine and provides everything else โ€” the APIs your code calls that arenโ€™t part of the language:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Browser runtime โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Node.js runtime โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ V8 engine (the language itself) โ”‚ โ”‚ V8 engine (the same language) โ”‚
โ”‚ + DOM (document, elements, events) โ”‚ โ”‚ + file system (fs), network sockets โ”‚
โ”‚ + fetch, timers, localStorage, canvas... โ”‚ โ”‚ + process, streams, fetch, timers... โ”‚
โ”‚ + the event loop (from the browser) โ”‚ โ”‚ + the event loop (from libuv) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

This is why document.querySelector doesnโ€™t exist in Node, and why fs.readFile doesnโ€™t exist in a browser โ€” neither is JavaScript. Theyโ€™re runtime APIs. The language โ€” closures, promises, arrays, objects โ€” is identical in both. Internalizing this split pays off constantly: when you read documentation, youโ€™ll know whether youโ€™re learning JavaScript (portable everywhere) or a runtimeโ€™s API (portable nowhere).

Notably, even things that feel core to JS โ€” setTimeout, console.log, fetch โ€” are runtime APIs, not language features. The ECMAScript spec doesnโ€™t define any of them.


What Happens When Your Code Runs

JavaScript is often called an โ€œinterpreted language,โ€ which was true in 1995 and is misleading now. Modern engines are sophisticated JIT (just-in-time) compilers, and the pipeline matters for understanding performance:

  1. Parse โ€” source code becomes an AST (abstract syntax tree). Syntax errors surface here, before anything runs.
  2. Baseline execution โ€” an interpreter (V8โ€™s is called Ignition) starts executing bytecode immediately. Fast to start, modest speed.
  3. Optimization โ€” the engine profiles as it runs. Functions that run hot get compiled to optimized machine code (V8โ€™s TurboFan), with aggressive assumptions based on observed behavior: โ€œthis variable has always been a number; compile arithmetic accordingly.โ€
  4. Deoptimization โ€” if an assumption breaks (that โ€œalways a numberโ€ variable suddenly gets a string), the engine throws away the optimized code and falls back. Correct behavior, big performance cliff.

You donโ€™t need to think about this daily, but it explains real phenomena: why JS can be shockingly fast (near-native for hot numeric loops), why performance advice says keep object shapes consistent and donโ€™t change a variableโ€™s type mid-flight, and why microbenchmarks lie (they measure whichever tier happened to be active).

One more execution fact that shapes the whole language: JavaScript is single-threaded. One call stack, one statement executing at a time. There is no โ€œspawn a threadโ€ in the core language. Instead, JS handles concurrency through the event loop โ€” an architecture where slow operations (network, timers, disk) are delegated to the runtime, and their callbacks run later, one at a time, when the stack is free. This design is why JS is so async-heavy โ€” callbacks, promises, async/await โ€” and itโ€™s important enough to get its own deep dive in this series. For now, hold the one-sentence version: JavaScript never waits; it schedules.


Where JavaScript Runs Now

The 1995 pitch was โ€œscripts for web pages.โ€ The 2026 reality:

The strategic consequence: JavaScript is the highest-leverage single language for anyone working near the web, because one language covers client, server, and tooling. Its flaws are real, but โ€œlearn it once, use it everywhereโ€ has proven to be an unbeatable proposition.

A note on TypeScript, because youโ€™ll meet it immediately: TypeScript is JavaScript plus a static type layer, compiled down to plain JS before running. It has become the default for serious projects. Everything in this series is TypeScript-relevant โ€” TS is JS at runtime โ€” and learning JS deeply first makes TSโ€™s type system make sense rather than feel like ritual.


Your First Real Look at the Language

You can follow this entire series with zero installation: every browser ships a console (F12 โ†’ Console tab), which is a full JS REPL. Or install Node and run node for the same thing in a terminal. Try this:

// values and variables โ€” const by default, let when reassignment is needed
const language = "JavaScript";
let age = 2026 - 1995;
// template literals โ€” modern string building
console.log(`${language} is ${age} years old`);
// functions are values you can pass around โ€” the heart of JS style
const twice = (f, x) => f(f(x));
const inc = (n) => n + 1;
console.log(twice(inc, 40)); // 42
// objects are ad-hoc and flexible
const engine = { name: "V8", vendor: "Google", browsers: ["Chrome", "Edge"] };
console.log(engine.browsers.length); // 2
// and the famous coercion quirks are real โ€” we'll tame them next chapter
console.log("5" + 1); // "51"
console.log("5" - 1); // 4

That fifth line โ€” passing a function to a function โ€” is the single most JavaScript thing in the snippet. Functions as first-class values shape everything: array methods, event handlers, promises, React components. If you come from Java, this is the mental shift; JS got lambdas-everywhere twenty years before Java 8 did.


A Map of the Weird (So It Doesnโ€™t Ambush You)

An honest orientation to the rough edges, each covered properly later in the series:

QuirkOne-line previewDeep dive
== vs ===== coerces types before comparing; always use ===Types & coercion
var hoistingvar ignores block scope; use let/constVariables & scope
thisDepends on how a function is called, not where itโ€™s writtenThe this keyword
ClosuresFunctions remember variables from where they were bornClosures
Async timingsetTimeout(fn, 0) doesnโ€™t run โ€œimmediatelyโ€Event loop
0.1 + 0.2 !== 0.3Floating point, same as every languageTypes & coercion

Two reassurances. First: the modern language, written with current idioms (const, ===, arrow functions, modules, async/await), avoids most of the traps by construction โ€” the quirks mostly live in the legacy half youโ€™ll learn to recognize and not write. Second: every quirk has a mechanical explanation. JS is not random; itโ€™s over-backward-compatible. The aim of this series is that nothing in the language feels like magic โ€” just history plus rules.


Frequently Asked Questions

Should I learn JavaScript or TypeScript first? JavaScript โ€” but briefly. Learn the core language (this series), then adopt TypeScript early in real projects. TS errors are incomprehensible without understanding the JS underneath; JS-without-types is unpleasant to maintain at scale. Theyโ€™re one skill with two stages, not competitors.

Do I need to learn jQuery / older patterns? No for new work; recognition-level only for maintaining old code. Modern DOM APIs (querySelector, fetch, classList) absorbed jQueryโ€™s good ideas years ago.

Which runtime should I practice in? Browser console for DOM-adjacent experiments, Node for everything else โ€” the language is identical. When this series touches runtime-specific APIs (like fetch or the DOM), it says so explicitly.

Is JavaScript slow? For the single-threaded, IO-heavy work it typically does โ€” no; V8 is an engineering marvel, and the event-loop model handles massive concurrency well. For CPU-parallel number crunching, itโ€™s the wrong tool (thatโ€™s what workers and WebAssembly patch over). Right tool, right job.

How much of this can AI tools write for me now? A lot of the typing โ€” and none of the judgment. Generated code with a subtle this bug, a swallowed promise rejection, or an accidental type coercion looks exactly like working code. The developers who thrive with AI assistance are the ones who can read a diff and spot whatโ€™s wrong โ€” which is precisely the mental-model knowledge this series builds.


Whatโ€™s Next

You now have the frame: a ten-day language standardized as ECMAScript, executed by JIT-compiling engines, embedded in runtimes that add the APIs, single-threaded with an event loop, evolving by addition, weird for explainable reasons.

Next: Variables and Scope โ€” let, const, the var youโ€™ll learn to recognize and avoid, hoisting, and the scoping rules that closures (the languageโ€™s crown jewel) are built on.