JavaScript array methods

name version Change the original array Detailed function
concat() ES5 n Combine the array and return the combined data
join() ES5 n Use the delimiter to convert the array to a string and return
pop() ES5 and Delete the last digit and return the deleted data
shift() ES5 and Delete the first place and return the deleted data
unshift() ES5 and Add one or more data in the first place and return the length
push() ES5 and Add one or more data to the last digit and return the length
reverse() ES5 and Reverse the array and return the result
slice() ES5 n Intercept the array at the specified position and return
sort() ES5 and Sort (character rules), return results
splice() ES5 and Delete the specified position and replace, return the deleted data
toString() ES5 n Convert directly to a string and return
valueOf() ES5 and Returns the original value of the array object
indexOf() ES5 n Query and return the index of the data, if not, return -1
lastIndexOf() ES5 n Reverse query and return the index of the data
forEach() ES5 n The parameter is a callback function, which will traverse all the items in the array. The callback function accepts three parameters, namely value, index, and self; forEach has no return value
map() ES5 n Same as forEach, at the same time the callback function returns data, forming a new array returned by map
filter() ES5 n Same as forEach, at the same time the callback function returns a boolean value, the data that is true form a new array returned by filter
every() ES5 n Same as forEach, at the same time the callback function returns a boolean value, all of which are true, and each returns true
some() ES5 n Same as forEach, at the same time the callback function returns a boolean value, as long as one is true, some returns true
reduce() ES5 n Merge, same as forEach, iterate all items in the array and build a final value, which is returned by reduce
reduceRight() ES5 n Reverse merge, same as forEach, iterate all items in the array and build a final value, which is returned by reduceRight

Guess you like

Origin blog.csdn.net/m0_46442996/article/details/115317970