Javascript Array remove(item, _delete)

Description

Javascript Array remove(item, _delete)


"use strict";//  ww  w .  j  av  a  2  s  .  com

Array.prototype.remove = function (item, _delete) {
  var i = this.indexOf(item);
  var arr = this;
  if (i > -1) {
    if (_delete) {
      delete arr[i];
    } else {
      arr = arr.splice(i, 1);
    }
  }
  return arr;
};



PreviousNext

Related