I\'m looking for a good JavaScript equivalent of the C/PHP printf() or for C#/Java programmers, String.Format() (IFormatProvider for .
printf()
String.Format()
IFormatProvider
I use this one:
String.prototype.format = function() { var newStr = this, i = 0; while (/%s/.test(newStr)) newStr = newStr.replace("%s", arguments[i++]) return newStr; }
Then I call it:
"%s%s".format("Header", "Just a test!");
%s