JS removes the beginning of the string or the first few characters. Slice can also be used to intercept a part

Source: Internet
Author: User

Pick Grass from W3

The slice () method returns the selected element from an existing array.

Grammar
Arrayobject.slice (Start,end)
Parameters Description
Start Necessary. Specify where to start the selection . If it is a negative number, it specifies the position from the end of the array . In other words, 1 refers to the last element, 2 refers to the second-lowest element, and so on.
End Optional. Specifies where to end the selection. The parameter is the array subscript at the end of the array fragment. If this parameter is not specified, then the segmented array contains all elements from start to end of the array. If this parameter is a negative number, it specifies the element starting from the end of the array.
return value

Returns a new array containing elements from start to end (excluding the element) from the Arrayobject.

Description

Note that the method does not modify the array, but instead returns a subarray. If you want to delete an element from an array, you should use Method Array.splice ().

Hints and Notes

Note: You can use negative values to select elements from the end of an array.

Note: If end is not specified, then the slice () method selects all elements from start to the end of the array.

JS removes the beginning of the string or the first few characters. Slice can also be used to intercept a part

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.