The format() method formats the number to a localized string.

Reset
"Code generation from strings disallowed for this context"

The formatToParts() method outputs an array with each part of the number separated by parts. This is useful for determining the properties of a locale, which can be useful for parsing numbers. See the parsing guide.

Reset
"Code generation from strings disallowed for this context"

Changing the numbering system

You can change the numbering system in your locale by adding -u-nu-{code}.

One common example is the Chinese locale of zh that uses latn as the default numbering system:

Reset
"Code generation from strings disallowed for this context"

But hanidec is also very common in this locale, and would look like this:

Reset
"Code generation from strings disallowed for this context"

Another way to change the numbering system is to specify the numberingSystem option.

Reset
"Code generation from strings disallowed for this context"

Number of Decimals Places

By default, decimals are rounded to 3 digits:

Reset
"Code generation from strings disallowed for this context"

To override the default number of decimal places, use the minimumFractionDigits option:

Reset
"Code generation from strings disallowed for this context"

Currency Formatting

To format a number as a currency, you need to set the style and currency options:

Reset
"Code generation from strings disallowed for this context"

Percent Formatting

To format a number as a percent, the number should be between 0 and 1, and the style should be set to percent:

Reset
"Code generation from strings disallowed for this context"

Full Intl.NumberFormat API Documentation