JavaScript

JavaScript is the programming language of the web — the only one that runs natively in every browser, handling everything from form validation to full single-page applications. With Node.js it also runs on servers, making it a true full-stack language with one syntax front to back.

Why it exists: Netscape created JavaScript in 1995 to make web pages interactive without full reloads (it's unrelated to Java despite the name — a marketing decision). Where it fits: it's one of the three core web technologies (HTML structure, CSS presentation, JS behavior). It's evolved enormously via the ECMAScript standard; modern JIT engines make it fast, and async/await tamed its famously tricky asynchronous model.

TL;DR

Quick Example

async/await makes asynchronous code read like synchronous code:

Core Concepts

Key terms

What beginners misunderstand

How JavaScript Works

JavaScript is single-threaded but non-blocking: long operations (network, timers) run elsewhere and their callbacks are queued, then run by the event loop when the stack is clear. The evolution went callbacks → Promises → async/await, the last of which is the modern default. Complexity tends to arise around async control flow, closures/memory, the this binding, and module systems (CommonJS vs ES Modules).

Runtimes & Variants

Common Uses

Tooling & Ecosystem

The ecosystem is overwhelmingly open-source; ECMAScript is developed openly by TC39, and engines (V8, SpiderMonkey, JavaScriptCore) are open-source. Proprietary layers focus on deployment (Vercel, Netlify, Cloudflare Workers).

Performance & Security

Performance bottlenecks: main-thread blocking (long synchronous work freezes the UI), memory leaks (closures, listeners, detached DOM nodes), large bundles (slow loads), and excessive re-renders in frameworks. Fixes: offload heavy work (Web Workers/WASM), split bundles and lazy-load, and profile before optimizing.

Security: prevent XSS (never inject unsanitized input into the DOM), avoid prototype pollution, audit npm dependencies, and never put secrets/API keys in client code.

Best Practices

Comparison

See TypeScript, Python, and WebAssembly.

Common Mistakes

== instead of ===

Forgetting await

Myths vs reality

FAQ

Is JavaScript the same as Java?

No — entirely different languages. The name was a 1995 marketing decision; their syntax, semantics, and use cases share nothing meaningful.

== or ===?

Use ===/!== by default. == performs surprising type coercion ("" == 0, null == undefined); strict equality compares type and value.

How does the this keyword work?

this is set by how a function is called: a method call binds it to the object, a plain call leaves it undefined (strict) or global, and arrow functions inherit this from their enclosing scope. Use arrow functions for callbacks when in doubt.

What is the event loop?

The mechanism that lets single-threaded JavaScript be non-blocking. Async operations run outside the main thread; their callbacks wait in a queue and the event loop runs them when the call stack is empty — which is why await doesn't freeze the page.

Should I use a framework or vanilla JS?

Vanilla JS is great for small, simple, or performance-critical work. Reach for a framework (React/Vue/Svelte) when you have lots of stateful UI to manage — it pays for its overhead in maintainability.

Related Topics

References