Arrays Cheatsheet
Array.map()
Returns a new array with the results of calling a function for every element.
Array.filter()
Returns a new array with all elements that passed the requirement of the provided function.
Array.reduce()
Reduce the array to a single value. which are all the elements added together.
Array.fill()
fill the elements in the array with the element that is defined.
Array.find()
Returns the value of the first element in the array that satisfies the provided testing function. Otherwise undefined is returned.
Array.indexOf()
Returns the first index at which a given element can be found in the array, or -1 if it is not present.
Array.includes()
Returns true if the given element is present in the array.
Array.pop()
Removes the last element from an array and returns that element.
Array.push()
Appends new elements to the end of an array, and returns the new length.
Array.shift()
Removes the first element from an array and returns that element.
Array.unshift()
Adds new elements to the beginning of an array, and returns the new length.
Array.splice()
Changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
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.
Array.join()
Joins all elements of an array into a string.
Array.reverse()
Reverses the order of the elements in an array.
Array.sort()
Sorts the elements of an array in place and returns the array ( doesn't work the same for numbers).
Array.some()
Returns true if at least one element in the array passes the test implemented by the provided function.
Array.of()
Creates a new array with a variable number of arguments, regardless of the number or type of the arguments.
Array.isArray()
Returns true if the given value is an array.
Array.at()
Returns a value at the specified index.
Array.copyWithin()
Copies array elements within the array. Returns the modified array.
Array.flat()
Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.
Hopefully, you enjoyed !