# Reference Guide

A quick reference for commonly used JavaScript methods and browser APIs.

Unless otherwise noted, these work in all modern browsers, and IE9+. You can extend support back further with polyfills.

🚀 For detailed tutorials, projects, and source code, check out my Vanilla JS Pocket Guides and Videos.

## 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

• Array.push() - Add items to an array.
• Array.concat() - Merge two or more arrays together.
• Array.slice() - Copy a segment of an array into a new array.
• Array.splice() - Delete, replace, and add items to an array at specific indexes.
• Array.from() - Create a new array from an existing array or array-like object.
• Array.map() - Transform the items in an array and create a new one.
• Array.filter() - Create a new array containing a subset of items from an existing ones.
• Array.reduce() - Take the content of an array and return a single value.
• Array.reverse() - Reverse the order of items in an array.
• Array.join() - Combine all items in an array into a string.
• Array.indexOf() - Get the index of the first matching item in an array.

## Distances

• window.pageYOffset - Get the distance a user has scrolled from the top of the page.
• getOffsetTop() - Get an element’s distance from the top of the document.