Javascript String format(data)

Description

Javascript String format(data)


String.prototype.format = function (data) {
  var string = this;

  for (var key in data) {
    string = string.split('{{' + key + '}}').join(data[key]);
  }//from   w  w w  . ja v  a2s  .c  o  m

  return string;
}



PreviousNext

Related