JavaScript (ES5 → ES2025) & TypeScript Basics
What it is & where it is used
JavaScript is the programming language of the web: it runs in every browser and, through Node.js, on servers, CLIs and build tools. It is dynamically typed, single-threaded with an event loop, prototype-based, and supports functional and object-oriented styles.
The language standard is ECMAScript (ECMA-262), maintained by TC39. Browsers implement it in engines: V8 (Chrome, Edge, Node.js), SpiderMonkey (Firefox), JavaScriptCore (Safari).
TypeScript (Microsoft, 2012) is a typed superset of JavaScript that compiles to JS — the default for Angular and widely used with React, Vue and Node.
Every frontend framework interview (jQuery, Angular, React, Vue) starts with JavaScript fundamentals: closures, this, the event loop, promises, var/let/const, prototypes and array methods.
Versions & history
| Version | Year | Key features |
|---|---|---|
| ES1 | 1997 | First standard (language created by Brendan Eich at Netscape in 10 days, 1995) |
| ES3 | 1999 | Regex, try/catch |
| ES5 | 2009 | "use strict", JSON, Array.prototype.forEach/map/filter/reduce, getters/setters, Object.create |
| ES6 / ES2015 | 2015 | let/const, arrow functions, classes, modules, promises, template literals, destructuring, default/rest/spread, Map/Set, symbols, iterators, generators |
| ES2016 | 2016 | Array.prototype.includes, ** |
| ES2017 | 2017 | async/await, Object.entries/values, string padding |
| ES2018 | 2018 | Object rest/spread, async iteration, Promise.finally, regex named groups |
| ES2019 | 2019 | Array.flat/flatMap, Object.fromEntries, optional catch binding |
| ES2020 | 2020 | Optional chaining ?., nullish coalescing ??, BigInt, Promise.allSettled, dynamic import(), globalThis |
| ES2021 | 2021 | String.replaceAll, Promise.any, logical assignment ??= ` |
| ES2022 | 2022 | Class fields and #private, top-level await, .at(), Object.hasOwn, error cause |
| ES2023 | 2023 | toSorted/toReversed/toSpliced/with (non-mutating), findLast |
| ES2024 | 2024 | Object.groupBy/Map.groupBy, Promise.withResolvers, resizable ArrayBuffer |
| ES2025 | 2025 | Iterator helpers (.map/.filter/.take on iterators), Set methods (union, intersection, difference...), Promise.try, JSON modules / import attributes, RegExp.escape |
TypeScript: 1.0 (2014), 2.0 (2016, strict null checks), 3.x, 4.x (2020–2023), 5.0 (2023, decorators standard), then regular 5.x releases. TypeScript 7 is a native port of the compiler to Go (codename "Project Corsa", previewed since 2025) that makes builds roughly 10× faster.
Lifecycle
How a browser runs JavaScript (page lifecycle):
- HTML parsed → DOM built; CSS → CSSOM;
<script>withoutdefer/asyncblocks parsing while it downloads and runs. deferscripts run in order after parsing;asyncscripts run as soon as downloaded (any order);type="module"is deferred by default.- DOMContentLoaded — DOM ready (deferred scripts done).
- load — all images, styles, iframes loaded.
- User interaction → events → event loop runs handlers.
- visibilitychange / pagehide → beforeunload → unload (avoid unload; use pagehide/visibilitychange).
Execution lifecycle of code: the engine parses source → creates the global execution context (creation phase: memory for variables/functions = hoisting; execution phase: runs line by line) → each function call pushes a new execution context on the call stack → returns pop it. Async callbacks wait in task queues until the stack is empty (the event loop).
Event loop order: run the current script (macrotask) → drain all microtasks (promise callbacks, queueMicrotask, MutationObserver) → render (requestAnimationFrame, style, layout, paint) → next macrotask (setTimeout, setInterval, I/O, UI events, MessageChannel).
Tools used to develop
| Tool | Use |
|---|---|
| Browser DevTools (Chrome/Edge/Firefox) | Console, debugger, network, performance, memory |
| VS Code | Editor with built-in JS/TS IntelliSense |
| Node.js + npm / pnpm / yarn / Bun | Runtime and package managers |
| Vite, webpack, esbuild, Rollup, Turbopack | Bundlers/dev servers |
TypeScript (tsc) | Type checking |
| ESLint, Prettier, Biome | Linting and formatting |
| Vitest, Jest, Mocha | Unit testing |
| Playwright, Cypress | End-to-end testing |
| Babel | Transpile modern JS for old browsers |
| Lighthouse, WebPageTest | Performance audits |
| caniuse.com, MDN | Compatibility and reference |