Javascript Array pushReplace(pattern)

Description

Javascript Array pushReplace(pattern)


Array.prototype.pushReplace = function(pattern){
  var args = Array.prototype.slice.call(arguments, 1);
  
  this.push(pattern.replace(/\{(\d+)\}/g, function(pattern, index){
    return args[index].toString();
  }));/*from w  w  w  . ja v  a2 s. c  o m*/
  return this;
};



PreviousNext

Related