.slice(start, end)
start,截取的位置 - 1 ;end,所截取最后一个字符的位置。
1、array.slice(start, end);
对原数组截取,并返回一个新数组,原数组不变。
2、string.slice(start, end);
对原字符串截取,并返回一个新字符串,原字符串不变。
.splice(start, length, item...)
start,开始位置;length,移除的数量;item,替换的元素
1、array.splice(start, length, item...);
从数组中移除一个或多个,并用新的item替换。
网友评论