Home > Web Front-end > JS Tutorial > body text

Getting started with the slice method of JavaScript string objects (for string interception)_Basic knowledge

WBOY
Release: 2016-05-16 16:33:39
Original
1139 people have browsed it

JavaScript slice method

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

Copy code The code is as follows:

str_object.replace(start, end)

Parameter description:

参数 说明
str_object 要操作的字符串(对象)
start 必需。要截取的开始位置,从 0 开始计算;如果为负数,则从字符串末尾反向开始计算
end 可选。要截取的结束位置,如果省略则到字符串结束;如果为负数,则从字符串末尾反向开始计算

slice method instance

Copy code The code is as follows:


Run this example, output:

Copy code The code is as follows:

bcdef
bc
ef
cd
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template