Array Methods Flashcards
.at()
The at() method takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array
.concat()
The concat() method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.
.copyWithin
The copyWithin() method shallow copies part of an array to another location in the same array and returns it without modifying its length.
.entries()
The entries() method returns a new Array Iterator object that contains the key/value pairs for each index in the array.
.every()
The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.
.fill()
The fill() method changes all elements in an array to a static value, from a start index (default 0) to an end index (default array.length). It returns the modified array.
.filter()
The filter() method creates a new array with all elements that pass the test implemented by the provided function.
.find()
The find() method returns the value of the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, undefined is returned.
.findIndex()
The findIndex() method returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test.
.flat()
The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.
.flatMap()
The flatMap() method returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level. It is identical to a map() followed by a flat() of depth 1, but slightly more efficient than calling those two methods separately.
.forEach()
The forEach() method executes a provided function once for each array element.
.from()
The Array.from() static method creates a new, shallow-copied Array instance from an array-like or iterable object.
.includes()
The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate.
.indexOf()
The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.