Here you can find the source of format()
String.prototype.format = function () { var str = this; for (var i = 0; i < arguments.length; i++) { var reg = new RegExp("\\{" + i + "\\}", "gm"); str = str.replace(reg, arguments[i]); }/*from w ww. j av a 2s. co m*/ return str; };
String.prototype.format = String.prototype.f = function () { var s = this, i = arguments.length; while (i--) { s = s.replace(new RegExp("\\{" + i + "\\}", "gm"), arguments[i]); return s; };
String.prototype.format = function() { var args = arguments; return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function(m, n) { if (m == "{{") { return "{"; if (m == "}}") { return "}"; return args[n]; }); };
String.prototype.format = function () { var str = this; for(var i = 0, j = arguments.length; i < j; i++){ str = str.replace(new RegExp('\\{' + i +'\\}', 'g'), arguments[i]); return str;
String.prototype.format = function() { var s = this, i = arguments.length; while (i--) { s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]); return s; };
String.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] != 'undefined' ? args[number] : '{' + number + '}' ; }); }; ...
'use strict'; String.prototype.format = function () { let str = this; for (let i = 0; i < arguments.length; i++) { let reg = new RegExp("\\{" + i + "\\}", "gm"); str = str.replace(reg, arguments[i]); return str; }; ...
String.prototype.format = function() { var txt = this; for (var i = 0; i < arguments.length; i++) { var exp = new RegExp('\\{' + (i) + '\\}', 'gm'); txt = txt.replace(exp, arguments[i]); return txt;
String.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] != 'undefined' ? args[number] : ''; }); };
'use strict'; String.prototype.format = function() { var content = this; for (var i = 0; i < arguments.length; i++) { var replacement = '{' + i + '}'; content = content.replace(replacement, arguments[i]); return content; }; ...