Nodejs Array Insert At insertAt(o, index)

Here you can find the source of insertAt(o, index)

Method Source Code

Array.prototype.insertAt = function (o, index) {
    if (index > -1 && index <= this.length) {
        this.splice(index, 0, o);/*from   w  w  w.  j  a  va 2 s  . c  om*/
        return true;
    }
    return false;
};

Related

  1. insertAt( index, value )
    Array.prototype.insertAt = function( index, value ) {
      var part1 = this.slice( 0, index );
      var part2 = this.slice( index );
      part1.push( value );
      return( part1.concat( part2 ) );
    };
    
  2. insertAt(arg, position)
    Array.prototype.insertAt = function(arg, position){
        this.splice(position, 0, arg);
    };
    
  3. insertAt(index, item)
    Array.prototype.insertAt = function(index, item) {
      this.splice(index, 0, item);
      return this;
    };
    
  4. insertAt(index,obj)
    Array.prototype.insertAt=function(index,obj){
        this.splice(index,0,obj);
    
  5. insertAt(index,obj)
    Array.prototype.insertAt=function(index,obj){
      this.splice(index,0,obj);