JavaScript
The programming language of the web browser, written in ten days in 1995, standardized as ECMAScript, and now run everywhere from servers to build tools despite quirks it can never remove.
JavaScript is the programming language built into every web browser, and through them the most widely deployed language in the world. Brendan Eich wrote the first version at Netscape in about ten days in May 1995. It was called Mocha, then LiveScript, and was renamed JavaScript for marketing, to ride the excitement around Java, a language it barely resembles.
To keep Microsoft's copy compatible, Netscape handed the language to the standards body Ecma International, so its official name is ECMAScript. Editions came slowly: ES3 in 1999, an ambitious ES4 abandoned in 2008, ES5 in 2009. ES2015 was the large overhaul, adding classes, modules, arrow functions, let and const, and promises. Since then a new edition ships every year, with proposals moving through public stages before they land.
Its design borrows from several places. Functions are first-class values that capture their surroundings, an idea from Scheme; see Closure. Objects inherit directly from other objects through prototypes, an idea from the language Self, rather than from classes. Variables have no declared types, and values convert into each other automatically when operators meet mismatched operands. That type coercion produces the language's famous puzzles: "5" - 1 is 4 but "5" + 1 is "51", and == compares loosely while === does not; see Type System. Every number is a 64-bit float, which is why 0.1 + 0.2 isn't 0.3.
JavaScript runs on one thread per page. Long work blocks clicks and rendering, so slow operations like network requests take callbacks and return later through a queue; see Event Loop and Promise. Memory is reclaimed automatically; see Garbage Collection.
It began as a slow interpreted language for small scripts. In 2008 Google's V8 engine compiled hot code to machine code as it ran, other browsers followed, and speed jumped by orders of magnitude. That made large browser applications practical, and the following year V8 was carried out of the browser to run servers.
The rule that governs the language is "don't break the web." Billions of pages depend on existing behavior, so mistakes are permanent: typeof null still returns "object", a bug from the first week; see Backward Compatibility. In 2018 a proposed array method named flatten had to be renamed flat, because an old library's own flatten would have broken sites that used it; see Hyrum's Law.
Most professional JavaScript is now written in something slightly different and translated before shipping, whether newer syntax for older browsers or types that are erased at build time.
See also2
TypeScript
Microsoft's typed superset of JavaScript, whose types are checked at build time and erased at runtime, and the deliberate trade-offs that made it the default for large web codebases.
Web Platform8 connections
Prototype Pollution
A JavaScript vulnerability where attacker-controlled keys like "__proto__" modify the prototype every object inherits from, silently adding properties everywhere, and how merge utilities and parsers let it in.
Web Platform10 connections
Linked from6
- ClosureComputation & Algorithms
A function bundled with the variables from its enclosing scope at the point it was created.
- EmojiDesign & Interface
Picture characters encoded in Unicode, born on Japanese phones in the late 1990s, drawn differently by every platform, and built from sequences of code points that break naive string handling.
- Event LoopComputation & Algorithms
A single-threaded runtime's mechanism for pulling the next callback off a queue once the call stack is empty.
- Prototype PollutionWeb Platform
A JavaScript vulnerability where attacker-controlled keys like "__proto__" modify the prototype every object inherits from, silently adding properties everywhere, and how merge utilities and parsers let it in.
- Type SystemTesting & Verification
The rules a language uses to classify values and reject operations that don't fit, checked before the program runs or as it runs, and the cheapest form of verification most programmers use every day.
- TypeScriptWeb Platform
Microsoft's typed superset of JavaScript, whose types are checked at build time and erased at runtime, and the deliberate trade-offs that made it the default for large web codebases.