Skip to content

Format String

Malexion edited this page Jan 5, 2017 · 4 revisions

Format a string template.

Should be familiar to those from .net, it should be noted that string concatenation, array join and interpolation are still 25% faster than this method.

Examples

var template = '{0}/{1}/{0}';

console.log(template.format('foo', 'bar'));

console.log('{0}/{1}'.format('foo', 'bar'));
Clone this wiki locally