Home > Article > Web Front-end > Instructions for using the slice() method in js_basic knowledge
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).