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. You can extend support back further with polyfills.
⏰ Last Chance! A new session of the Vanilla JS Academy started this week, but it's not too late to join. Sign up today and get 25% off registration.
Selectors
Loops
Classes
Styles
Attributes
Event Listeners
Strings
Numbers
- parseInt() - Convert a string into an integer (whole number).
- parseFloat() - Convert a string into a point number (a number with decimal points).
- Number() - Convert a string into a number.
- Number.toFixed() - Format a number to a fixed number of decimal places.
- Number.toString() - Convert a number to a string.
- Basic math - Do basic arithmetic with JavaScript.
- Comparisons - Compare two numbers.
- Math.abs() - Get the absolute value of a number.
- Math.floor() - Get the largest integer less than or equal to a number.
- Math.ceil() - Get the smallest integer greater than or equal to a number.
- Math.max() - Get the largest number from a set of numbers
- Math.min() - Get the lowest number from a set of numbers.
- Math.random() - Return a random float between
0
and 1
.
Arrays
Objects
HTML and Text
DOM Injection
Traversing the DOM
The Viewport
Distances
Browser Storage
- Cookies - 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 and APIs
JavaScript-Free Components