15 methods of arrays

22:43 2020/7/311. 15 methods of array
push add the return array length at the end
unshift add the return array length at the head
pop() delete at the end
shift() delete
slice() at the head start position, end position , If there is only one parameter, that is, there is no end position parameter, from start to end. If the end position is greater than the start position, return the empty array
splice() start position, delete the number and return the deleted element
reverse() flip the array
map() and Similar to foreach, this method is to call a provided function for each element in the array,
and the result is returned as a new array, without changing the original array (map will also traverse each item of the array), it is worth Note that map will not detect empty arrays.
join() converts the data stored in the array into a string and stores
concat() concatenation of arrays, concatenate multiple arrays into one array
sort() arrange the array
every from small to large () Judge each value in the array, as long as one is not satisfied, it will return false, otherwise it will be true.
filter() picks out the values ​​that meet the conditions in the array and returns them as an array.
map() handles each value in the array accordingly, and returns the processed value as an array.
value() The value used to fill the array elements
sttr() Start index
end() End index The default value is this.length
The some() and every() methods are similar, the difference is that. Every as long as one does not meet the condition, it returns false, and as long as there is one, some returns true.

Guess you like

Origin blog.csdn.net/weixin_48116269/article/details/109172474