Home  >  Article  >  Web Front-end  >  Instructions for using the slice() method in js_basic knowledge

Instructions for using the slice() method in js_basic knowledge

WBOY
WBOYOriginal
2016-05-16 19:17:131633browse

This Javascript example explains: This example uses the Slice(start,[end]) method of the Array object. This method returns a new array that contains the elements specified by the source function from start to end, but does not include the end element. , such as a.slice(0,3); if start is negative, treat it as length start, where length is the length of the array, such as a.slice(-3,4), which is equivalent to a.slice(2, 4). If end is negative, it is treated as length end, where length is the length of the array, such as a.slice(0,-1). If end is omitted, the slice method will copy to the end of the source array, such as a.slice(1). If end appears before start, no elements are copied to the new array, such as a.slice(4,3).


[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]
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