Here you can find the source of format()
String.prototype.format = function() { var formatted = this; for (var i = 0; i < arguments.length; i++) { var regexp = new RegExp('\\{'+i+'\\}', 'gi'); formatted = formatted.replace(regexp, arguments[i]); }/*www. j av a 2 s. com*/ return formatted; };
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]); return str; };
'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; }; ...
String.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] !== 'undefined' ? args[number] : match ; }); }; ...
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 formatted = this, i, size = arguments.length; for (i = 0; i < size; i++) { var regexp = new RegExp('\\{' + i + '\\}', 'gi'); formatted = formatted.replace(regexp, arguments[i]); return formatted; };