Home  >  Article  >  Web Front-end  >  Array object method reference_basic knowledge

Array object method reference_basic knowledge

WBOY
WBOYOriginal
2016-05-16 19:25:461084browse

concat method: Returns a new array, which is a combination of two or more arrays. array1.concat([item1[, item2[, . . . [, itemN]]]])

join method: Returns a string value that contains all the elements of the array connected together, the elements are separated by the specified delimiter. arrayObj.join(separator)

pop method: Removes the last element in the array and returns that element. arrayObj.pop()

push method: Adds new elements to an array and returns the new length value of the array. arrayObj.push([item1 [item2 [. . . [itemN ]]]])

reverse method: Returns an Array object with the order of elements reversed. arrayObj.reverse( )

shift method: Remove the first element in the array and return that element. arrayObj.shift( )

slice method: Returns a segment of an array. arrayObj.slice(start, [end])

sort method: Returns an Array object whose elements have been sorted. arrayobj.sort(sortfunction)

splice method: Remove one or more elements from an array, insert a new element at the position of the removed element if necessary, and return the removed element. arrayObj.splice(start, deleteCount, [item1[, item2[, . . . [,itemN]]]])

unshift method: Insert the specified element into the beginning of the array and return the array. arrayObj.unshift([item1[, item2 [, . . . [, itemN]]]])

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn