NumberFormat

The declaration of a NumberFormat has the form:

new Intl.NumberFormat([locales[, options]])

A related function is: Number.prototype.toLocaleString()(8.9.3)

'locales' is a string with a BCP 47 language tag, or an array of such strings. The following Unicode extension key is allowed:
nuThe numbering system to be used. Possible values include: "arab", "arabext", "bali", "beng", "deva", "fullwide", "gujr", "guru", "hanidec", "khmr", "knda", "laoo", "latn", "limb", "mlym", "mong", "mymr", "orya", "tamldec", "telu", "thai", "tibt".
'options' is an object with some or all of the following properties:
RESETRUNFULL
<!DOCTYPE html><html><body><script>

localeMatcherThe locale matching algorithm to use. Possible values are "lookup" and "best fit"; the default is "best fit". For information about this option, see the Intl page.

</script></body><html>

<!DOCTYPE html><html><body><script>

styleThe formatting style to use. Possible values are "decimal" for plain number formatting, "currency" for currency formatting, and "percent" for percent formatting; the default is "decimal".

</script></body><html>

<!DOCTYPE html><html><body><script>

currencyDisplayHow to display the currency in currency formatting. Possible values are "symbol" to use a localized currency symbol such as €, "code" to use the ISO currency code, "name" to use a localized currency name such as "dollar"; the default is "symbol".

</script></body><html>

<!DOCTYPE html><html><body><script>

useGroupingWhether to use grouping separators, such as thousands separators or thousand/lakh/crore separators. Possible values are true and false; the default is true.

</script></body><html>

<!DOCTYPE html><html><body><script>

minimumIntegerDigitsThe minimum number of integer digits to use. Possible values are from 1 to 21; the default is 1.

</script></body><html>

<!DOCTYPE html><html><body><script>

minimumFractionDigitsThe minimum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number and percent formatting is 0; the default for currency formatting is the number of minor unit digits provided by the ISO 4217 currency code list (2 if the list doesn't provide that information).

</script></body><html>

<!DOCTYPE html><html><body><script>

maximumFractionDigitsThe maximum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number formatting is the larger of minimumFractionDigits and 3; the default for currency formatting is the larger of minimumFractionDigits and the number of minor unit digits provided by the ISO 4217 currency code list (2 if the list doesn't provide that information); the default for percent formatting is the larger of minimumFractionDigits and 0.

</script></body><html>

<!DOCTYPE html><html><body><script>

minimumSignificantDigitsThe minimum number of significant digits to use. Possible values are from 1 to 21; the default is 1.

</script></body><html>

<!DOCTYPE html><html><body><script>

maximumSignificantDigitsThe maximum number of significant digits to use. Possible values are from 1 to 21; the default is minimumSignificantDigits.

</script></body><html>

RESETRUNFULL
<!DOCTYPE html><html><body><script>

var n = 123456.789;var l10nEN = new Intl.NumberFormat("en-US");var l10nDE = new Intl.NumberFormat("de-DE");console.log(l10nEN.format(n)); // 123,456.789console.log(l10nDE.format(n)); // 123.456,789var l10nUSD = new Intl.NumberFormat("en-US",
                              { style: "currency", currency: "USD" });var l10nGBP = new Intl.NumberFormat("en-GB",
                              { style: "currency", currency: "GBP" });var l10nEUR = new Intl.NumberFormat("de-DE",
                              { style: "currency", currency: "EUR" });console.log(l10nUSD.format(n)); // $123,456.79console.log(l10nGBP.format(n)); // £123,456.79console.log(l10nEUR.format(n)); // 123.456,79 €console.log(JSON.stringify(l10nEUR.resolvedOptions()));/* {"locale":"de", "numberingSystem":"latn", "style":"currency", "useGrouping":true, "minimumIntegerDigits":1, "minimumFractionDigits":2, "maximumFractionDigits":2, "currency":"EUR", "currencyDisplay":"symbol"} */console.log(new Intl.NumberFormat().format(n));                                                                         // 123,456.789console.log(new Intl.NumberFormat('de-DE').format(n));                                                               // 123.456,789console.log(new Intl.NumberFormat('ar-EG').format(n));                                                               // → ١٢٣٤٥٦٫٧٨٩console.log(new Intl.NumberFormat('en-IN').format(n));                                                               // 1,23,456.789console.log(new Intl.NumberFormat(
                            'zh-Hans-CN-u-nu-hanidec').format(n));                                                        // 一二三,四五六.七八九console.log(new Intl.NumberFormat(['ban','id']).format(n));                                                         // 123.456,789                                                                                         // fallback to 'id'console.log(Intl.NumberFormat.supportedLocalesOf( ['ban', 'id-u-co-pinyin', 'de-ID'], { localeMatcher: 'lookup' }).join(', ')); // id-u-co-pinyin, de-ID

</script></body><html>