Nodejs String Insert insert(index, string)

Here you can find the source of insert(index, string)

Method Source Code

Object.size = function(obj) {
    var size = 0, key;
    for (key in obj) {
        if (obj.hasOwnProperty(key)) size++;
    }/*from   ww w .  j a  va  2  s.co m*/
    return size;
};

String.prototype.insert = function (index, string) {
  if (index > 0)
    return this.substring(0, index) + string + this.substring(index, this.length);
  else
    return string + this;
};

Related

  1. insert(index, string)
    String.prototype.insert = function (index, string) {
      if (index > 0)
        return this.substring(0, index) + string + this.substring(index, this.length);
      else
        return string + this;
    };
    
  2. insert(index, string)
    String.prototype.insert = function (index, string) {
      if (index > 0) {
        return this.substring(0, index) + string + this.substring(index, this.length);
      else {
        return string + this;
    };
    
  3. insert(start, new_string)
    String.prototype.insert = function(start, new_string)
      return this.slice(0, start) + new_string + this.slice(start);
    };
    String.prototype.splice = function(start, length, insert)
      return this.substring(0, start) + insert + this.substring(start + length);
    };
    Object.prototype.extend = function(other)
    ...
    
  4. insert(start, new_string)
    String.prototype.insert = function(start, new_string)
      return this.slice(0, start) + new_string + this.slice(start);
    };
    String.prototype.splice = function(start, length, insert)
      return this.substring(0, start) + insert + this.substring(start + length);
    };
    Object.prototype.extend = function(other)
    ...
    
  5. insert(start, new_string)
    String.prototype.insert = function(start, new_string)
      return this.slice(0, start) + new_string + this.slice(start);
    };
    String.prototype.splice = function(start, length, insert)
      return this.substring(0, start) + insert + this.substring(start + length);
    };