Skip to content

String.prototype.formatArray()

Marcel Kloubert edited this page Feb 13, 2015 · 2 revisions

String.prototype.formatArray([args]) method

Handles the string as format string and returns the formatted version.

The behaviour is similar to the String.Format() method of the .NET-Framework.

Syntax

String.prototype.formatArray([args]);

Parameters

Name Type Description
args Array [OPTIONAL] The arguments for the format string.

Result

The formatted string.

Examples

// 'TM+MK'
var res1 = '{0}+{1}'.formatArray(['TM', 'MK']);
// '1+2+3=6'
var res2 = '{1}+{3}+{0}={2}'.formatArray([3, 1, 6, 2]);
Clone this wiki locally