Here you can find the source of format()
// Global JS//from w w w . j a v a2 s . c o m 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 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) { ...
String.prototype.format= function(){ var args = arguments; return this.replace(/\{(\d+)\}/g,function(s,i){ return args[i]; }); function confirmdel(str){ return confirm(str);
String.prototype.format = function() { var formattedString = this; var strArray = Array.prototype.slice.call(arguments); var pattern; strArray.forEach(function(value, index) { pattern = new RegExp("\\{" + index + "\\}", "g"); formattedString = formattedString.replace(pattern, value && typeof value === 'string' ? value : ''); }); return formattedString; ...
String.prototype.format = function () { var formatted = this; if (arguments != null) { for (var i = 0; i < arguments.length; i++) { while (formatted.indexOf("{" + i + "}") > -1) { formatted = formatted.replace("{" + i + "}", 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 = function() { var res = this; for (var i = 0; i < arguments.length; i++) { res = res.replace(new RegExp("\\{" + (i) + "\\}", "g"), arguments[i]); return res; };
String.prototype.format = function() { var args = arguments; return this.replace(/\$\{([A-Za-z0-9_]+)\}/g, function(base, element, position) { for (var i = 0; i < args.length; i++) { if (args[i] != null && typeof(args[i][element]) != "undefined") return args[i][element]; if (typeof(args[element - 1]) == "undefined") return base; ...