string slice_JavaScript中带示例的String slice()方法

string slice

JavaScript | 字符串slice()方法 (JavaScript | String slice() Method)

The String.slice() method in JavaScript is used to return a part of the string. The starting and ending index of the part to be sliced is provided as the parameter of the string.

JavaScript中的String.slice()方法用于返回字符串的一部分。 提供要切片的部分的开始和结束索引作为字符串的参数。

Syntax:

句法:

    String.slice(startIndex, endIndex);

Parameter(s):

参数:

The method accepts two parameters, they are the starting and ending index of the sliced string which is extracted.

该方法接受两个参数,它们是提取的切片字符串的开始和结束索引。

Return value:

返回值:

The return type of this method is string which is the sliced output of the given string.

此方法的返回类型是string ,它是给定字符串的切片输出。

Browser support: Chrome, Internet explorer, Mozilla, Safari, Opera mini.

浏览器支持: Chrome,Internet Explorer,Mozilla,Safari,Opera mini。

Example:

例:

str = "includehelp"
//"includehelp"
str.slice(6)
//"ehelp"
str.slice(0,7)
//"include"
str.slice(6,-1)
//"ehel"


翻译自: https://www.includehelp.com/code-snippets/string-slice-method-with-example-in-javascript.aspx

string slice

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值