Array.prototype.concat()
var new_array = old_array.concat(value1[, value2[, …[, valueN]]])
Parameters:
ValueN: optional
Arrays and/or values will be merged into a new array. If all valueN arguments are omitted, concat returns a shallow copy of the existing array that called the method.
Return New array instance
Array.prototype.copyWithin()
The copyWithin() method shallowly copies part of the array to another location in the same array and returns it without changing the length of the original array.
arr.copyWithin(target[, start[, end]])
-
target
-
0 is the base index, and the sequence is copied to that position. If it is negative, target will count from the end.
-
If target is greater than or equal to arr.length, no copy will occur. If target is after start, the copied sequence is modified to match arr.length.
-
start
-
0 is the base index at which the copy element starts. If it is negative, start is evaluated from the end.
-
If start is ignored, copyWithin will start copying from 0.
-
end
-
0 is the index of the base and the end position of the start copy element. CopyWithin will be copied to that location, but not to the end element. If it is negative, end is evaluated from the end.
-
If end is ignored, the copyWithin method is copied all the way to the end of the array (arr.length by default).
Return the original array, but the original array has been changed
Array.prototype.entries()
The Entries () method returns a new Array Iterator containing the key/value pairs for each index in the Array.
Return a new Array iterator object. The iterator object is an object with a prototype next method that iterates through the Array to get the [key, value] of the original Array.
Array.prototype.every()
arr.every(callback(element[, index[, array]])[, thisArg])
ThisArg thisArg thisArg thisArg thisArg thisArg thisArg thisArg thisArg thisArg
Every returns true only when the callback returns true each time
Function return value: A Boolean value used to determine whether each item in the array qualifies as a callback function
Array.prototype.fill()
arr.fill(value[, start[, end]])
Value is the value used to populate an array element
Start is the start index. The default value is 0
End is the terminating index and the default value is this
Return The modified array
Array.prototype.filter()
var newArray = arr.filter(callback(element[, index[, array]])[, thisArg])
The parameter meaning is similar to the previous method
Return a new array of elements that pass the test, or an empty array if none of the elements pass the test.
Array.prototype.find()
The find() method returns the value of the first element in the array that satisfies the provided test function. Otherwise return undefined.
arr.find(callback(element[, index[, array]])[, thisArg])
Callback is a callback with a condition, and the first element that meets the condition is the returned element
Return the value of the first element in the array that satisfies the provided test function, otherwise undefined is returned.
Array.prototype.findIndex()
The findIndex() method returns the index of the first element in the array that satisfies the provided test function. Returns -1 if no corresponding element is found.
This is similar to find except that the return value is an index value
Array.prototype.flat()
The Flat () method recurses through the array of numbers at a specified depth and returns all the elements in a new array combined with the elements in the traversed subarray.
var newArray = arr.flat([depth])
Copy the code
Depth is optional. The default value is 1
Return a new array
Array.prototype.flatMap()
FlatMap can be understood as map and then automatic flat, and it is only one layer
The received parameter rules are the same as those for map
Return a new array in which each element is the result of the callback function and the structure depth is 1.
Array.prototype.forEach()
The forEach() method performs the given function once on each element of the array.
return undefined;
Array.prototype.includes()
The includes() method is used to determine whether an array contains a specified value, returning true if it does and false otherwise.
arr.includes(valueToFind[, fromIndex])
Copy the code
ValueToFind is the element value to look up.
FromIndex optional
Start looking for valueToFind at the fromIndex index. If it is negative, the search starts in ascending order from array.length + fromIndex’s index (even if you skip the fromIndex absolute index from the end and then search backwards). The default is 0.
Return Boolean value
Array.prototype.indexOf()
The indexOf() method returns the first index in the array where a given element can be found, or -1 if none exists.
arr.indexOf(searchElement[, fromIndex])
Copy the code
SearchElement: The element to find
FromIndex (optional), the default value is 0. If negative numbers are passed, this is used as an offset at the end of the array, where -1 means the search starts from the last element. If the offset index is still less than 0, the entire array is queried.
Return The index position of the first element found in the array; If none is found, -1 is returned
Array.prototype.join()
The join() method joins all the elements of an array (or an array-like object) into a string and returns the string. If the array has only one item, that item is returned without a delimiter.
arr.join([separator])
Copy the code
Separator Optional: By default, the separator press “,” to concatenate the elements in the array. If separator is an empty string (“”), there are no characters between the elements.
Return a string that concatenates all array elements. If arr.length is 0, an empty string is returned.