JavaScript Array slice() Method Exampleġ. If either argument start or end is a negative value, it specifies an array element relative to the last element in the array. In other words, the returned array contains the element specified by the first parameter start and all subsequent elements up to, but not including element the specified by the second parameter end. If both start and end indexes are specified, the slice() method creates a sequence of elements that begins from the start index up till the end index – 1. In other words, the returned array contains all elements from the starting to ending of the array. If only one parameter (index value) is specified, the slice() method creates a sequence of elements that begins from index and ends on the last array element. A new array that contains the sliced out or extracted elements. The slice() method returns a shallow copy of elements from the original array. The slice() method of Array object comes into two flavors that are as: array.slice(index)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |