Getting started with the slice Method of a JavaScript string object (used for string truncation) _ basic knowledge

Source: Internet
Author: User
This article mainly introduces the slice Method Entry Example of the JavaScript string object. The slice method is used to capture strings by specifying the start and end positions. For more information, see JavaScript slice Method

The slice method is used to intercept a part of a string and return the string. The syntax is as follows:

The Code is as follows:


Str_object.replace (start, end)

Parameter description:

Parameters Description
Str_object String (object) to be operated)
Start Required. Start position of the string to be truncated. The value starts from 0. If the value is negative, the value starts from the reverse end of the string.
End Optional. The end position of the string to be truncated. If it is omitted, it ends with the end of the string. If it is a negative number, it is calculated from the reverse end of the string.

Slice Method Instance

The Code is as follows:


Related Article

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.