I use:
String.prototype.format = function() { var s = this, i = arguments.length; while (i--) { s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]); } return s; };
usage: "Hello {0}".format("World");
I found it in String.format Equivalent in jQuery
UPDATED:
In ES6 / ES2015 you can use string templating for example
'use strict'; let firstName = 'John', lastName = 'Smith'; console.log(`Full Name is ${firstName} ${lastName}`);
Vlad Bezden Feb 18 2018-11-14T00: 00Z
source share