删除数组中对应的元素

 //查找数组中的val 的下标
  Array.prototype.indexOf = function(val) {
    for (var i = 0; i < this.length; i++) {
    if (this[i] == val) return i;
    }
    return -1;
  }
  //找对数值对应下标,删除
  Array.prototype.remove = function(val) {
    var index = this.indexOf(val);
    if (index > -1) {
    this.splice(index, 1);
    }
  };

//调用
['4','5','6'].remove('5');//['4','6']

  

原文地址:https://www.cnblogs.com/adouwt/p/7852162.html