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: