Roadmap › 4. Frontend › Step 43
JS

JavaScript (ES5 → ES2025) & TypeScript Basics

Types, scope, hoisting, closures, this, prototypes, classes, the event loop, promises and async/await, modules, DOM and events, fetch, ES6+ features, error handling, performance, security and TypeScript essentials.
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
VersionYearKey features
ES11997First standard (language created by Brendan Eich at Netscape in 10 days, 1995)
ES31999Regex, try/catch
ES52009"use strict", JSON, Array.prototype.forEach/map/filter/reduce, getters/setters, Object.create
ES6 / ES20152015let/const, arrow functions, classes, modules, promises, template literals, destructuring, default/rest/spread, Map/Set, symbols, iterators, generators
ES20162016Array.prototype.includes, **
ES20172017async/await, Object.entries/values, string padding
ES20182018Object rest/spread, async iteration, Promise.finally, regex named groups
ES20192019Array.flat/flatMap, Object.fromEntries, optional catch binding
ES20202020Optional chaining ?., nullish coalescing ??, BigInt, Promise.allSettled, dynamic import(), globalThis
ES20212021String.replaceAll, Promise.any, logical assignment ??= `
ES20222022Class fields and #private, top-level await, .at(), Object.hasOwn, error cause
ES20232023toSorted/toReversed/toSpliced/with (non-mutating), findLast
ES20242024Object.groupBy/Map.groupBy, Promise.withResolvers, resizable ArrayBuffer
ES20252025Iterator 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):

  1. HTML parsed → DOM built; CSS → CSSOM; <script> without defer/async blocks parsing while it downloads and runs.
  2. defer scripts run in order after parsing; async scripts run as soon as downloaded (any order); type="module" is deferred by default.
  3. DOMContentLoaded — DOM ready (deferred scripts done).
  4. load — all images, styles, iframes loaded.
  5. User interaction → events → event loop runs handlers.
  6. 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
ToolUse
Browser DevTools (Chrome/Edge/Firefox)Console, debugger, network, performance, memory
VS CodeEditor with built-in JS/TS IntelliSense
Node.js + npm / pnpm / yarn / BunRuntime and package managers
Vite, webpack, esbuild, Rollup, TurbopackBundlers/dev servers
TypeScript (tsc)Type checking
ESLint, Prettier, BiomeLinting and formatting
Vitest, Jest, MochaUnit testing
Playwright, CypressEnd-to-end testing
BabelTranspile modern JS for old browsers
Lighthouse, WebPageTestPerformance audits
caniuse.com, MDNCompatibility and reference