JavaScript
The programming language of the web. Runs in every browser and on servers (Node.js). JavaScript makes web pages interactive — handling clicks, fetching data, updating the DOM, and building full applications. It's dynamically typed, single-threaded with an event loop, and multi-paradigm.
- All web frontends.
- Backend services via Node.js for I/O-heavy workloads.
- Cross-platform apps (React Native, Electron).
- CPU-intensive compute (use Rust/Go/Python with native extensions).
- Systems programming.
Definition
JavaScript is a high-level, dynamically typed, garbage-collected language with first-class functions, prototype-based OOP, and an event loop for async I/O. ES6+ added classes, modules, async/await, arrow functions, and destructuring. It runs in browsers (via V8/SpiderMonkey) and servers (Node.js, Deno, Bun).
Why it exists
Browsers needed a scripting language for client-side interactivity. JavaScript won the browser war and grew into a general-purpose language via Node.js.
How it works
The JS engine parses, compiles (JIT), and executes code on a single thread with an event loop. Async operations (I/O, timers, fetch) use callbacks/promises/async-await without blocking. The DOM API lets JS manipulate the page. Node.js uses V8 without the browser DOM.
Scaling limits
Single-threaded (one CPU core for JS; workers help). Dynamic types catch errors at runtime, not compile time (TypeScript fixes this). Large codebases need module systems and tooling.
Cost shape
Free and open. The cost is build tooling (bundlers, transpilers) and runtime performance tuning.
Alternatives
- TypeScript — Adds static types to JS; safer but needs compilation.
- WebAssembly — Run compiled languages in the browser for CPU-heavy work.
Failure modes
- Runtime type errors (no compile-time checks without TS).
- Blocking the event loop freezing the UI.
- Callback hell (mitigated by async/await).