Javascript Array removeItem(itemToRemove)

Description

Javascript Array removeItem(itemToRemove)


'use strict';// ww w.  java  2 s . co  m

/*jslint eqeq: true*/

Array.prototype.removeItem = function (itemToRemove) {

 var index = this.indexOf(itemToRemove);
 var itemFoundInArray = (index != -1);
 if (itemFoundInArray) {
  this.splice(index, 1); // remove item at that index
 }
};



PreviousNext

Related