Here you can find the source of format()
/*NameSpace Protection */ var testSuite = testSuite || {}; String.prototype.format = function() { var formatted = this; for( var arg in arguments ) { formatted = formatted.replace("{" + arg + "}", arguments[arg]); }/* w w w.j a va 2 s .c o m*/ return formatted; }; var testSuite = function (tableResultId){ this.tableId = tableResultId; var self = this; /*Should Change to promote backwards compatibility*/ QUnit.testDone((details) => self.AddResult(details)); }; testSuite.prototype.AddResult = function(result){ // console.log(this.tableId); var row = $("<tr><td>{0}</td><td>{1}/{2}</td><td>{3}</td></tr>".format(result.name,result.passed,result.total,result.runtime)); $("{0} > tbody".format('#' + this.tableId)).append(row); };
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++) { var arg = args[i]; if (arg && typeof(arg) == "object") { try { if (arg[element] !== undefined) return arg[element]; ...
String.prototype.format = function () { var args = arguments; this.unkeyed_index = 0; return this.replace(/\{(\w*)\}/g, function (match, key) { if (key === '') { key = this.unkeyed_index; this.unkeyed_index++ if (key == +key) { ...
'use strict'; String.prototype.format = function () { var str = this; for (var i = 0; i < arguments.length; i++) { var regEx = new RegExp("\\{" + (i) + "\\}", "gm"); str = str.replace(regEx, arguments[i]); return str;
String.prototype.format = function () { var args = arguments; return this.replace(/{(\d+)}/g, function (match, number) { if (typeof args[number] != 'undefined') { return args[number]; return ""; }); }; ...
String.prototype.format = function () { var str = this; for ( var i = 0; i < arguments.length; i ++ ) { str = str.replace( '{' + i + '}', arguments[ i ] ); return str;
String.prototype.format = String.prototype.format = function() { var s = this, i = arguments.length; while (i--) { s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]); return s; };
define(function () { return { currentDate: function () { var date = new Date(); var dd = date.getDate(); var mm = date.getMonth() + 1; var yyyy = date.getFullYear(); var hh = date.getHours(); var MM = date.getMinutes(); ...
String.prototype.format = function () { var o = Array.prototype.slice.call(arguments); return this.replace(/{([^{}]*)}/g, function (match, capture) { var r = o[capture]; return (typeof r === 'string' || typeof r === 'number') ? r : match; ); }; ...
String.prototype.format = function() { var args = arguments; return this.replace(/\{(\d+)\}/g, function(orig,num) { return typeof args[num] != 'undefined' ? args[num] : orig; }); };