Nodejs Array Append Item add(obj)

Here you can find the source of add(obj)

Method Source Code

/**//from ww  w  . j  ava 2 s .c  om
 * Appends the specified element into the end of this array.
 * @param obj the element to be appended to this array.
 * @return return the position of the appended element.
 */
Array.prototype.add = function (obj) {
    var i = this.length;
    this[i] = obj;
    return i;
};

Related

  1. add(element)
    Array.prototype.add = function(element) {
      var newSize = this.push(element);
      return newSize-1;
    
  2. add(elemento,duplicado)
    Array.prototype.add = function(elemento,duplicado) {
      if(duplicado===false){
        for (var i = 0; i < this.length; i++) {
          if(this[i]===elemento)
            return;
      this[this.length] = elemento;
    
  3. add(index, element)
    Array.prototype.add = function(index, element) {
      if (arguments.length == 2) {
        this.splice(index, 0, element);
      } else {
        this.push(index);
    };
    
  4. add(index, item)
    Array.prototype.add = function(index, item){
      if (item === undefined){
        item = index;
        index = 0;
      while (index > this.length){
        this.push(undefined);
      this.splice(index, 0, item);
    ...
    
  5. add(item)
    var SEP = ',';
    Array.prototype.add = function(item) {
        for ( var i = 0; i < this.length; i++) {
            if (this[i] === item) {
                return this;
        this[this.length] = item;
        return this;
    ...
    
  6. add(other)
    Array.prototype.add = function(other) {
        console.assert(this.length == other.length, 'add: len(a) != len(b)');
        var ret = new Array(this.length);
        for(var i = 0; i < ret.length; i++)
            ret[i] = this[i] + other[i];
        return ret;
    
  7. add(value)
    "use strict";
    Array.prototype.add = function(value) {
        this.push(value);