The Number toLocaleString() method returns a number as a string, using locale settings.
<!-- html element to place output -->
<p id="my_output"></p>
// variables
let my_value = 100;
let my_number = my_value.toLocaleString();
// output to the HTML element
document.getElementById('my_output').innerHTML = my_number;
Output
100
Syntax
number.toLocaleString(locales, options)
Parameters
Value
Description
locales
ar-SA Arabic
bn-BD Bangla
bn-IN Bangla
cs-CZ Czech
da-DK Danish
de-AT Austrian German
de-CH "Swiss" German
de-DE Standard German
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
fr-BE Belgian French
fr-CA Canadian French
fr-CH "Swiss" French
fr-FR Standard French
he-IL Hebrew
hi-IN Hindi
hu-HU Hungarian
id-ID Indonesian
it-CH "Swiss" Italian
it-IT Standard Italian
ja-JP Japanese
ko-KR Korean (Republic of Korea)
nl-BE Belgian Dutch
nl-NL Standard Dutch
no-NO Norwegian
pl-PL Polish
pt-BR Brazilian Portuguese
pt-PT European Portuguese (Portugal)
ro-RO Romanian
ru-RU Russian
sk-SK Slovak
sv-SE Swedish
ta-IN Indian Tamil
ta-LK Sri Lankan Tamil
th-TH Thai
tr-TR Turkish
zh-CN Mainland China (simplified characters)
zh-HK Hong Kong (traditional characters)
zh-TW Taiwan (traditional characters)
options
currency:
any currency code (like "EUR", "USD", "INR", etc.)
timeStyle: currencyDisplay:
"symbol" (default)
"code"
"name"
localeMatcher:
"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:
"currency"
"decimal" (default)
"percent"
useGrouping
"true" (default)
"false"
JavaScript Notes:
When using JavaScript, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
JavaScript is a case-sensitive language; firstName is NOT the same as firstname
Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on
JavaScript variables must begin with a letter, $, or _
JavaScript variables are case sensitive (x is not the same as X)
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.