Skip to content
This repository has been archived by the owner on Oct 23, 2021. It is now read-only.

sp core library.text_2.format

John Nguyen edited this page Apr 22, 2021 · 2 revisions

Home > @microsoft/sp-core-library > Text_2 > format

Text_2.format() method

Format a string by substituting parameters.

Signature:

static format(s: string, ...values: unknown[]): string;

Parameters

Parameter Type Description
s string
values unknown[]

Returns:

string

Remarks

This function replaces template parameters such as "{0}" or "{1}" with the corresponding argument. If the value is null or undefined, it will be replaced by the word "null" or "undefined". The format string s must not be null or undefined.

Usage example:

Text.format("hello {0}!", "world") will return "hello world!"

Clone this wiki locally