Here you can find the source of format()
/*/* w w w .j a v a 2 s .c om*/ * file: strings.js * description: used to provide C# / Python-style format strings to JS string objects * author: Aaron Stannard * created: 8/12/2013 * last-modified: 8/12/2013 */ 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 = 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 txt = this, i = arguments.length; while (i--) { txt = txt.replace ( new RegExp('\\{' + i + '\\}', 'gm'), 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] : match; }); };
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 = 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;
String.prototype.format = function () { var formatted = this; for (var i = 0; i < arguments.length; i++) { formatted = formatted.replace( RegExp('\\{' + i + '\\}', 'g'), arguments[i]); return formatted; };
String.prototype.format = function() { var formattedString = this; for (var i = 0; i < arguments.length; i++) { var reg = new RegExp('\\{' + i + '\\}', 'gm'); formattedString = formattedString.replace(reg, arguments[i]); return formattedString; };
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 formatted = this; if(arguments.length == 1 && arguments[0] instanceof Object) { var args = arguments[0]; for(var i in args) { var regexp = new RegExp('\\{' + i + '\\}', 'gi'); formatted = formatted.replace(regexp, args[i]); } else if(arguments.length > 1) { ...