Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Array Methods
let array = []
// Joins two or more arrays, and returns a copy of the joined arrays
array.concat(otherArray)
// Copies array elements within the array, to and from specified positions
array.copyWithin(target, start, end)
// Returns a key/value pair Array Iteration Object
array.entries()
// Checks if every element in an array pass a test
array.every((currentValue, index, arr) => {}, thisValue)
// Fill the elements in an array with a static value
array.fill(value, start, end)
// Creates a new array with every element in an array that pass a test
array.filter((currentValue, index, arr) => {}, thisValue)
// Returns the value of the first element in an array that pass a test
array.find((currentValue, index, arr) => {}, thisValue)
// Returns the index of the first element in an array that pass a test
array.findIndex((currentValue, index, arr) => {}, thisValue)
// Calls a function for each array element
array.forEach((currentValue, index, arr) => {}, thisValue)
// Creates an array from an object
array.from(object, mapFunction, thisValue)
// Check if an array contains the specified element
array.includes(element, start)
// Search the array for an element and returns its position
array.indexOf(item, start)
// Checks whether an object is an array
array.isArray(obj)
// Joins all elements of an array into a string
array.join(separator)
// Returns a Array Iteration Object, containing the keys of the original array
array.keys()
// Search the array for an element, starting at the end, and returns its position
array.lastIndexOf(item, start)
// Creates a new array with the result of calling a function for each array element
array.map((currentValue, index, arr) => {}, thisValue)
// Removes the last element of an array, and returns that element
array.pop()
// Adds new elements to the end of an array, and returns the new length
array.push(item1, item2, ..., itemX)
// Reduce the values of an array to a single value (going left-to-right)
array.reduce((total, currentValue, currentIndex, arr) => {}, initialValue)
// Reduce the values of an array to a single value (going right-to-left)
array.reduceRight((total, currentValue, currentIndex, arr) => {}, initialValue)
// Reverses the order of the elements in an array
array.reverse()
// Removes the first element of an array, and returns that element
array.shift()
// Selects a part of an array, and returns the new array
array.slice()
// Checks if any of the elements in an array pass a test
array.some((currentValue, index, arr) => {}, thisValue)
// Sorts the elements of an array
array.sort(compareFunction())
// Adds/Removes elements from an array
array.splice(index, howmany, item1, ..., itemX)
// Converts an array to a string, and returns the result
array.toString()
// Adds new elements to the beginning of an array, and returns the new length
array.unshift(item1, item2, ..., itemX)
// Returns the primitive value of an array
array.valueOf()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment