copyWithin
语法
Array.prototype.copywithin(index, startIndex, endIndex)
index
复制的数组项开始替换的起始索引值
start
复制的数组项的起始位置
end
复制的数组项的结束位置(不包含)
应用
删除数组中某一项
[].copyWithin(index, index + 1).pop()
置顶数组某一项
Array.prototype.top = function(index) {
const value = this[index]
this.copyWithin(1, 0, index)
this[0] = value
}
以自己现在的努力程度,还没有资格和别人拼天赋

浙公网安备 33010602011771号