Skip to content

String.format method

String › format

Official

Formats a string using the indexed placeholders.

Signature:

format(args?: string[]): string

Parameters:

Parameter Type Description
args? string[] The arguments to format the string with.

Returns: stringThe formatted string.

Example:

console.log('foo {0} bar {1} baz {0}'.format('qux', 'quux')); // foo qux bar quux baz qux