移出数组中某项
2020-12-07 本文已影响0人
在下高姓
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
let a=[1,2,3,4,6,5]
a.remove(0)
console.log(a)//[2,3,4,6,5]