toLocaleString()

Обновлено: 15.03.2023

Визначення та використання

Повертає toLocaleString()число як рядок у форматі місцевої мови.

Формат мови залежить від налаштувань мови на вашому комп’ютері.

Синтаксис

number.toLocaleString(locales, options)

Параметри

ParameterDescription
localesOptional.
The language specific format to use.
Click on the "Try it" button to see all values in action.

ar-SA Arabic (Saudi Arabia)
bn-BD Bangla (Bangladesh)
bn-IN Bangla (India)
cs-CZ Czech (Czech Republic)
da-DK Danish (Denmark)
de-AT Austrian German
de-CH "Swiss" German
de-DE Standard German (as spoken in Germany)
el-GR Modern Greek
en-AU Australian English
en-CA Canadian English
en-GB British English
en-IE Irish English
en-IN Indian English
en-NZ New Zealand English
en-US US English
en-ZA English (South Africa)
es-AR Argentine Spanish
es-CL Chilean Spanish
es-CO Colombian Spanish
es-ES Castilian Spanish (as spoken in Central-Northern Spain)
es-MX Mexican Spanish
es-US American Spanish
fi-FI Finnish (Finland)
fr-BE Belgian French
fr-CA Canadian French
fr-CH "Swiss" French
fr-FR Standard French (especially in France)
he-IL Hebrew (Israel)
hi-IN Hindi (India)
hu-HU Hungarian (Hungary)
id-ID Indonesian (Indonesia)
it-CH "Swiss" Italian
it-IT Standard Italian (as spoken in Italy)
ja-JP Japanese (Japan)
ko-KR Korean (Republic of Korea)
nl-BE Belgian Dutch
nl-NL Standard Dutch (as spoken in The Netherlands)
no-NO Norwegian (Norway)
pl-PL Polish (Poland)
pt-BR Brazilian Portuguese
pt-PT European Portuguese (as written and spoken in Portugal)
ro-RO Romanian (Romania)
ru-RU Russian (Russian Federation)
sk-SK Slovak (Slovakia)
sv-SE Swedish (Sweden)
ta-IN Indian Tamil
ta-LK Sri Lankan Tamil
th-TH Thai (Thailand)
tr-TR Turkish (Turkey)
zh-CN Mainland China, simplified characters
zh-HK Hong Kong, traditional characters
zh-TW Taiwan, traditional characters
optionsOptional.
An object with formatting options:

currencyLegal values: any currency code (like "EUR", "USD", "INR", etc.)
currencyDisplay
Legal values:
"symbol" (default)
"code"
"name"
localeMatcher
Legal values:
"best-fit" (default)
"lookup"
maximumFractionDigits
A number from 0 to 20 (default is 3)
maximumSignificantDigits
A number from 1 to 21 (default is 21)
minimumFractionDigits
A number from 0 to 20 (default is 3)
minimumIntegerDigits
A number from 1 to 21 (default is 1)
minimumSignificantDigits
A number from 1 to 21 (default is 21)
style
Legal values:
"currency"
"decimal" (default)
"percent"
useGrouping
Legal values:
"true" (default)
"false"

Повернене значення

Типопис
РядокРядок, що представляє число в локальному форматі.

Підтримка браузера

toLocaleString()є функцією ECMAScript3 (ES3).

ES3 (JavaScript 1999) повністю підтримується в усіх браузерах:

number toLocaleString

Посмотреть совместимость на Can I use?

number toLocaleString