Nodejs String Insert insertAt(index, stringInserted)

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

Method Source Code

/**//w  ww .j av  a2 s .  co m
 * Return a new string, with the string argument inserted at the specified index
 * 
 * @param {Object} index
 * @param {Object} string
 */
String.prototype.insertAt = function (index, stringInserted) {
  if (index > 0)
    return this.substring(0, index) + stringInserted + this.substring(index, this.length);
  else
    return stringInserted + stthisring;
};

Related

  1. insertAt(b,a)
    String.prototype.insertAt=function(b,a){
      return(this.valueOf().substr(0,b))+a+(this.valueOf().substr(b))
    };
    
  2. insertAt(idx, rem, text)
    String.prototype.insertAt = function(idx, rem, text){
      return (this.slice(0,idx) + text + this.slice(idx + Math.abs(rem)));
    };
    
  3. insertAt(index, string)
    String.prototype.insertAt=function(index, string) {
        return this.substr(0, index) + string + this.substr(index);
    };
    
  4. insertAt(index, string)
    String.prototype.insertAt = function (index, string) {
      return [this.slice(0, index), string, this.slice(index)].join('');
    };
    String.prototype.bind = function (attr) {
      var str = this,
        regex = /(?:data\-bind\-(\w+)="(\w+)")/g,
        match,
        matches = {};
      while (match = regex.exec(str)) {
    ...
    
  5. insertAt(index, string)
    String.prototype.insertAt = function(index, string) {
        return [this.slice(0, index), string, this.slice(index)].join('');
    };
    
  6. insertComma()
    String.prototype.insertComma = function () {
        var string = this;
        var temporary = "";
        while (string != (temporary = string.replace(/^([+-]?\d+)(\d\d\d)/, "$1,$2"))) {
            string = temporary;
        return string;