移出数组中某项

 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]

你可能感兴趣的:(移出数组中某项)