Here you can find the source of format()
String.prototype.format = function() { // usage example: '{0} is {1}'.format('this', 'great'); var res = this; for (var i = 0; i < arguments.length; i++) { res = res.replace(new RegExp("\\{" + (i) + "\\}", "g"), arguments[i]); }//from www . ja v a 2 s.c om return res; };
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; for( var arg in arguments ) { formatted = formatted.replace("{" + arg + "}", arguments[arg]); return formatted; };
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 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; ...
String.prototype.format = function(){ var fn = String.format; switch (arguments.length) { case 1: return fn(this, arguments[0]); case 2: return fn(this, arguments[0], arguments[1]); case 3: return fn(this, arguments[0], arguments[1], arguments[2]); ...
String.prototype.format = function () { var str = this, args = arguments; return str.replace(String.prototype.format.regex, function(item) { var intVal = parseInt(item.substring(1, item.length - 1)), replace; if (intVal >= 0) { replace = args[intVal]; } else if (intVal === -1) { ...
String.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] != 'undefined' ? args[number] : match ; }); }; ...