Extends the Array object, creating a "addItem" method on it. - Node.js Array

Node.js examples for Array:Add Element

Description

Extends the Array object, creating a "addItem" method on it.

Demo Code

Array.prototype.addItem = function( item )
{
  var i = this.length ;
  this[ i ] = item ;//  w w  w  . j a  v  a  2s.  co  m
  return i ;
}

Related Tutorials