Here you can find the source of format()
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]); }//from www .j av a 2s. c o m return formatted; };
'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 ; }); }; ...
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; for (var i = 0; i < arguments.length; i++) { var regexp = new RegExp('\\{'+i+'\\}', 'gi'); formatted = formatted.replace(regexp, arguments[i]); return formatted; }; var ch = function(o) { ...
String.prototype.format = function() { var formatted = this; for( var arg in arguments ) { formatted = formatted.replace("{" + arg + "}", arguments[arg]); return formatted; };
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; }; ...
'use strict'; String.prototype.format = function () { var args = arguments; return this.replace(/{(\d+)}/g, function (match, number) { if (typeof args[number] !== 'undefined') { return args[number]; } else { return match; }); };