Looking how to format string in the way Node.js does, I found this answer in StackOverflow.
Download the string-formatter.js
file and put it at the top of the scripts chain in the HTML file.
If you use bower
$ bower install --save string-formatter
Is really simple. Just write a C# formatting-like string, and use the format
function indicating the parameters to be replaced, the magic is done by this library.
console.log('How to {0} this {1}? Just {0} it!'.format('use', 'library'));
// --> How to use this library? Just use it!
Now, if you attempt to format using a parameter number which is lower than 0 or upper than the items' number, it will return the same {#} string:
console.log('I will feed my {0} with {9} fish and {-1} bodies'.format('cat', 'fresh', 'dead'));
// --> I will feed my cat with {9} fish and {-1} bodies