字符串的slice方法_字符串slice()方法

字符串的slice方法

Return a new string from the part of the string included between the begin and end positions.

beginend位置之间包含的字符串部分返回一个新字符串。

The original string is not mutated.

原始字符串未更改。

end is optional.

end是可选的。

'This is my car'.slice(5) //is my car
'This is my car'.slice(5, 10) //is my

If you set a negative first parameter, the start index starts from the end, and the second parameter must be negative as well, always counting from the end:

如果将第一个参数设置为负,则起始索引从末尾开始,第二个参数也必须为负,始终从末尾开始计数:

'This is my car'.slice(-6) //my car
'This is my car'.slice(-6, -4) //my

翻译自: https://flaviocopes.com/javascript-string-slice/

字符串的slice方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值