Some methods of Js array

The following are no less than fifteen JS array methods
rlength: returns or sets the number of elements in an array.
from(): Convert pseudo-arrays or iterable objects (including arguments, Array, Map, Set, String...) to array objects.
isArray(): Used to determine whether the passed value is an Array.
concat(): The method is used to merge two or more arrays. This method does not alter the existing array, but returns a new array.
every(callback): The method tests whether all elements of the array pass the test of the specified function.
filter(callback): Returns a new array containing all elements that pass the test fulfilled by the provided function.
find(callback): Returns the value of the first element in the array that satisfies the provided test function.
findIndex(callback): Returns the index of the first element in the array that satisfies the provided test function, without returning -1.
forEach(callback): The method executes the provided function once for each element of the array.
some(callback): Determine whether some elements in the array satisfy the result of the callback function, as long as one is satisfied, return true otherwise false.
sort(callback): When the position of the array is sorted, the results can be returned in ascending or descending order according to the value passed in, and the array is returned.
map(callback): Returns an array whose result is the result of calling a provided function for each element in the array.
reduce(callback): The accumulator and each element in the array (from left to right) finally returns the accumulated value.
includes(): Used to determine whether an array contains a specified value, returning true or false.
indexOf(): Returns the first index where a given element can be found in the array, or -1 if it does not exist.
join(): Joins all elements of an array (or an array-like object) into a string.
lastIndexOf(): Returns the last index of the specified element (that is, a valid JavaScript value or variable) in the array, or -1 if it does not exist. Look forward from the back of the array.
pop(): Removes the last element from the array and returns the value of that element.
push(): Adds an element to the end of the array.
shift(): Deletes the first element in the array and returns the value of that element.
slice(): returns a shallow copy of a portion of an array selected from start to end (not including end) into a new array object
splice(): changes the contents of an array by removing existing elements and/or adding new elements
toString( ): returns a string representing the specified array and its elements
unshift(): adds one or more elements to the beginning of the array and returns the length of the new array
toLocaleString(): returns a string representing the elements in the array. The elements in the array will be converted to strings using their respective toLocaleString methods, and these strings will use a locale-specific string (such as a comma ",")

Guess you like

Origin blog.csdn.net/tianyhh/article/details/129112774