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