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 .
đ Relaunch Sale! Today through this weekend, get 30% off any vanilla JS pocket guide or bundle . They've been completely updated with new methods and modern JS approaches.
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
Get Daily Developer Tips
I send out a short email each weekday with code snippets, tools, techniques, and interesting stuff from around the web. Join 11,900+ daily subscribers.