JavaScript is the language of the web: it runs in every browser and, with a runtime, on servers and tools. TypeScript is JavaScript with a static type system that compiles away to plain JavaScript. Together they are the usual way to build interactive pages and a large share of web back ends, so the quirks of the base language are worth learning properly.
Key concepts
- Functions and closures: first-class functions are the core of the language, and closures capture variables.
- Objects and prototypes: objects are bags of properties linked by a prototype chain; classes are syntax over it.
- Event loop: one thread runs callbacks from a queue; nothing blocks if you do not make it.
- Asynchronous code: promises and async functions describe work that finishes later.
- Modules: files that export and import values, the basis of every project.
- Types in TypeScript: structural types, unions, generics and inference that check code before it runs.
Vocabulary
- DOM: the document object model, the tree of a page that scripts read and change.
- Coercion: the language's automatic conversion between types, a source of surprises.
- Transpiler and bundler: tools that convert and combine source into what the browser runs.
- Runtime: an environment that runs JavaScript outside a browser.
What to study, in order
- Variables, functions, arrays, objects and control flow in the browser's console.
- Closures, this, prototypes and the surprising rules of equality and coercion.
- The DOM and events: build a small interactive page with no framework.
- Promises, async functions and fetching data from a service.
- Modules and a package manager, then add TypeScript to the project.
- Learn the event loop well enough to predict the order of output of a mixed example.