A language tour
Designed in ten days in 1995, deployed on every device by 2025 — the accidental language that runs the world.
01 — Flexibility
JavaScript doesn't force you into one way of thinking. It supports procedural, object-oriented, and functional programming — sometimes by design, sometimes because nobody said no.
// Procedural function greet(name) { return "Hello, " + name + "!"; } // Object-oriented class Person { constructor(name) { this.name = name; } greet() { return "Hello, " + this.name + "!"; } } // Functional const greet = (name) => `Hello, ${name}!`;
All three styles compile to the same bytecode-free runtime — you can mix paradigms in a single file, for better or worse.
02 — Prototypes
JavaScript's prototype system is different from classical inheritance. Objects inherit directly from other objects — no blueprints required.
"In JavaScript, objects inherit from objects. What could be more object-oriented than that?"
— Douglas Crockford// Create an object const animal = { speak() { return "I make sounds"; } }; // Inherit from it const dog = Object.create(animal); dog.speak = () => "Woof!"; console.log(dog.speak()); // "Woof!" console.log(Object.getPrototypeOf(dog).speak()); // "I make sounds" — walks the chain
Object.create(animal) sets the prototype chain directly — no class, no constructor, just an object whose lookups fall through to another object.
03 — Asynchronous
JavaScript was built for the web, where waiting would freeze the UI. Promises and async/await make asynchronous code readable.
// Promises chain naturally fetch('/api/data') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(error)); // Async/await reads like sync code async function loadData() { try { const response = await fetch('/api/data'); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } }
async/await is syntax sugar over Promises — the same event loop, the same microtask queue, but code that reads top to bottom.
04 — Functions
In JavaScript, functions are values. You can pass them around, return them, and even create them on the fly.
// Functions as parameters function process(array, callback) { return array.map(callback); } const numbers = [1, 2, 3]; const doubled = process(numbers, n => n * 2); // Functions returning functions function multiplier(factor) { return (number) => number * factor; } const double = multiplier(2); const triple = multiplier(3); console.log(double(5)); // 10 console.log(triple(5)); // 15
multiplier returns a closure — double and triple are distinct functions that each remember the factor they were created with.
05 — Dynamic
JavaScript objects are just collections of properties. You can add, remove, and modify them at runtime.
// Objects start empty const user = {}; // Add properties dynamically user.name = "Alice"; user.age = 30; user["favorite-color"] = "blue"; // Computed property names const key = "dynamic"; const obj = { [key]: "value", ["computed" + "Key"]: "another value" }; // Destructuring const { name, age } = user; console.log(`Hello ${name}, you are ${age}`);
Objects are mutable dictionaries — flexible containers for any data structure.
06 — The Whole Picture
JavaScript's story is a contradiction: rushed to market in ten days, then standardised by committee across a decade, then quietly shipped on more machines than any language in history.
Browsers, servers, IoT devices, the command line. JavaScript did not plan to run everywhere — it just does.
Supports multiple paradigms, evolves with the web, and hosts countless frameworks and libraries.
Built for interactivity — callbacks, promises, and async/await handle the asynchronous nature of the web.
Objects inherit from objects, not classes. A different kind of object-oriented programming.
npm hosts over two million packages. That's a feature and a hazard in equal measure.
TC39 and annual updates keep JavaScript modern while maintaining backward compatibility.