Adds the element to the array. - Node.js Array

Node.js examples for Array:Add Element

Description

Adds the element to the array.

Demo Code

/**//  w w w.  jav  a2 s .  com
 * Adds the element to the array.
 *
 * @param element the element to add.
 * @return the index of the element.
 */
Array.prototype.add = function(element) {
  var newSize = this.push(element);

  return newSize-1;
}

Related Tutorials