Javascript Array removeItem(index)

Description

Javascript Array removeItem(index)


Array.prototype.removeItem = function(index) {
  if(isNaN(index) || index > this.length) {
    return false;
  }/* w  w w  .j av a2s. co  m*/

    for (var i = 0; i < this.length; i++) {
        if (i > index) {
            this[i-1] = this[i];
        }
    }
    this.length -= 1;
};



PreviousNext

Related