Arrays Cheatsheet

Array.map()

Returns a new array with the results of calling a function for every element. image.png

Array.filter()

Returns a new array with all elements that passed the requirement of the provided function. image.png

Array.reduce()

Reduce the array to a single value. which are all the elements added together. image.png

Array.fill()

fill the elements in the array with the element that is defined. image.png

Array.find()

Returns the value of the first element in the array that satisfies the provided testing function. Otherwise undefined is returned. image.png

Array.indexOf()

Returns the first index at which a given element can be found in the array, or -1 if it is not present. image.png

Array.includes()

Returns true if the given element is present in the array. image.png

Array.pop()

Removes the last element from an array and returns that element. image.png

Array.push()

Appends new elements to the end of an array, and returns the new length. image.png

Array.shift()

Removes the first element from an array and returns that element. image.png

Array.unshift()

Adds new elements to the beginning of an array, and returns the new length. image.png

Array.splice()

Changes the contents of an array by removing or replacing existing elements and/or adding new elements in place. image.png

Array.slice()

Returns a shallow copy of a portion of an array into a new array object selected from beginning to end. The original array will not be modified. image.png

Array.join()

Joins all elements of an array into a string. image.png

Array.reverse()

Reverses the order of the elements in an array. image.png

Array.sort()

Sorts the elements of an array in place and returns the array ( doesn't work the same for numbers). image.png

Array.some()

Returns true if at least one element in the array passes the test implemented by the provided function. image.png

Array.of()

Creates a new array with a variable number of arguments, regardless of the number or type of the arguments. image.png

Array.isArray()

Returns true if the given value is an array. image.png

Array.at()

Returns a value at the specified index. image.png

Array.copyWithin()

Copies array elements within the array. Returns the modified array. image.png

Array.flat()

Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. image.png

                                        Hopefully, you enjoyed !