Chapter 14 Cheatsheet: Runtimes

This cheatsheet summarizes the ecosystem, runtimes, and tooling of JavaScript covered in Chapter 14.

Runtimes

A runtime environment is where your JavaScript executes, providing the host APIs (like Network or File System access) your code needs.

  • Frontend: Browsers (Chrome, Firefox, Safari)
  • Backend: Node.js, Deno, Bun

Node.js & Tooling

Node.js allows JS execution on local machines and servers.

  • NVM (Node Version Manager): Used to easily install and switch between different versions of Node.js (nvm use 22).
  • NPM (Node Package Manager): The central registry for JS packages.
  • package.json: The core configuration file generated by npm init, tracking dependencies and defining custom CLI scripts.

The DOM

The Document Object Model is the browser’s programmatic representation of an HTML page. JavaScript uses the document API to read, manipulate, and attach event listeners to HTML nodes.

Standards and Compatibility

  • ECMAScript (ES): The official technical specification that defines how the JavaScript language works. Updated yearly (ES6, ES2022, etc.).
  • Polyfill: A code snippet that manually adds modern methods (like new Array functions) to older browsers.
  • Transpiler (e.g., Babel): A tool that rewrites modern syntax (like async/await) into older syntax to guarantee cross-browser compatibility.