美文网首页
移出数组中某项

移出数组中某项

作者: 在下高姓 | 来源:发表于2020-12-07 12:01 被阅读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]

相关文章

网友评论

      本文标题:移出数组中某项

      本文链接:https://www.haomeiwen.com/subject/hsgzwktx.html