0
点赞
收藏
分享

微信扫一扫

js删除数组里面的某一个值

诗与泡面 2023-05-19 阅读 87


在main.js中

Array.prototype.remove = function(val) {
      var index = this.indexOf(val);
      if (index > -1) {
        this.splice(index, 1);
      }
    };

使用

var array= ['abs','dsf','sdf','fd']
    array.remove('fd');
    console.log(array);


举报

相关推荐

0 条评论