Home > Web Front-end > JS Tutorial > js comes with function memo array_basic knowledge

js comes with function memo array_basic knowledge

WBOY
Release: 2016-05-16 19:22:06
Original
778 people have browsed it
For the slice function of array objects,

returns a segment of an array. (Still an array)

arrayObj.slice(start, [end])
Parameters
arrayObj
Required. An Array object.
start
Required. The starting element of the specified portion of arrayObj is a zero-based index.
end
Optional. The end element of the portion specified in arrayObj is the zero-based index.
Description
The slice method returns an Array object, which contains the specified part of arrayObj. The

slice method copies up to, but not including, the element specified by end. If start is negative, treat it as length start, where length is the length of the array. If end is negative, it is treated as length end, where length is the length of the array. If end is omitted, the slice method will copy until the end of arrayObj. If end appears before start, no elements are copied to the new array.

Example
In the following example, all elements in myArray except the last element are copied to newArray:

newArray = myArray.slice(0, - 1) Another function contact for arrays, used to connect two arrays concat
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template