Reference Guide
A quick reference for commonly used JavaScript methods and browser APIs.
Unless otherwise noted, these work in all modern browsers on desktop and mobile.
⏰ Preorder my new course on Web Components! Want to learn how to build Web Components from scratch, master best practices, and more? Preorder today and get $100 off of the launch price.
Selectors
Loops
- for - Loop through arrays and array-like objects.
- for...of - Loop over iterable objects.
- for...in - Loop over plain objects.
- forEach() - Loop through arrays and NodeLists.
Classes
Styles
Attributes & Properties
Event Listeners
Strings
Numbers
Arrays
Objects
Variables & Functions
HTML & Text
DOM Injection
Traversing the DOM
The Viewport
Browser Storage
- Cookies - Get and set cookie values.
- localStorage - Store data locally in the browser for later use.
- sessionStorage - Store data locally for the duration of the current browser session.
JSON
Ajax & APIs
- fetch() - Make Promise-based HTTP request.
- Promise.all() - Wait for two or more asynchronous tasks to resolve.
- async & await - Write asynchronous code like it’s synchronous.
ES Modules
JavaScript-Free Components
⏰ Preorder my new course on Web Components! Want to learn how to build Web Components from scratch, master best practices, and more? Preorder today and get $100 off of the launch price.