运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Numbers</h1> <h2>The toLocaleString() Method</h2> <p>toLocaleString() returns a number as a string, using local language format.</p> <p>Legal language codes:</p> <p id="demo"></p> <code> <script> let n = 1000000; let text = ""; text += "ar-SA: " + n.toLocaleString("ar-SA") + "<br>"; text += "bn-BD: " + n.toLocaleString("bn-BD") + "<br>"; text += "bn-IN: " + n.toLocaleString("bn-IN") + "<br>"; text += "cs-CZ: " + n.toLocaleString("cs-CZ") + "<br>"; text += "da-DK: " + n.toLocaleString("da-DK") + "<br>"; text += "de-AT: " + n.toLocaleString("de-AT") + "<br>"; text += "de-CH: " + n.toLocaleString("de-CH") + "<br>"; text += "de-DE: " + n.toLocaleString("de-DE") + "<br>"; text += "el-GR: " + n.toLocaleString("el-GR") + "<br>"; text += "en-AU: " + n.toLocaleString("en-AU") + "<br>"; text += "en-CA: " + n.toLocaleString("en-CA") + "<br>"; text += "en-GB: " + n.toLocaleString("en-GB") + "<br>"; text += "en-IE: " + n.toLocaleString("en-IE") + "<br>"; text += "en-IN: " + n.toLocaleString("en-IN") + "<br>"; text += "en-NZ: " + n.toLocaleString("en-NZ") + "<br>"; text += "en-US: " + n.toLocaleString("en-US") + "<br>"; text += "en-ZA: " + n.toLocaleString("en-ZA") + "<br>"; text += "es-AR: " + n.toLocaleString("es-AR") + "<br>"; text += "es-CL: " + n.toLocaleString("es-CL") + "<br>"; text += "es-CO: " + n.toLocaleString("es-CO") + "<br>"; text += "es-ES: " + n.toLocaleString("es-ES") + "<br>"; text += "es-MX: " + n.toLocaleString("es-MX") + "<br>"; text += "es-US: " + n.toLocaleString("es-US") + "<br>"; text += "fi-FI: " + n.toLocaleString("fi-FI") + "<br>"; text += "fr-BE: " + n.toLocaleString("fr-BE") + "<br>"; text += "fr-CA: " + n.toLocaleString("fr-CA") + "<br>"; text += "fr-CH: " + n.toLocaleString("fr-CH") + "<br>"; text += "fr-FR: " + n.toLocaleString("fr-FR") + "<br>"; text += "he-IL: " + n.toLocaleString("he-IL") + "<br>"; text += "hi-IN: " + n.toLocaleString("hi-IN") + "<br>"; text += "hu-HU: " + n.toLocaleString("hu-HU") + "<br>"; text += "id-ID: " + n.toLocaleString("id-ID") + "<br>"; text += "it-CH: " + n.toLocaleString("it-CH") + "<br>"; text += "it-IT: " + n.toLocaleString("it-IT") + "<br>"; text += "ja-JP: " + n.toLocaleString("ja-JP") + "<br>"; text += "ko-KR: " + n.toLocaleString("ko-KR") + "<br>"; text += "nl-BE: " + n.toLocaleString("nl-BE") + "<br>"; text += "nl-NL: " + n.toLocaleString("nl-NL") + "<br>"; text += "no-NO: " + n.toLocaleString("no-NO") + "<br>"; text += "pl-PL: " + n.toLocaleString("pl-PL") + "<br>"; text += "pt-BR: " + n.toLocaleString("pt-BR") + "<br>"; text += "pt-PT: " + n.toLocaleString("pt-PT") + "<br>"; text += "ro-RO: " + n.toLocaleString("ro-RO") + "<br>"; text += "ru-RU: " + n.toLocaleString("ru-RU") + "<br>"; text += "sk-SK: " + n.toLocaleString("sk-SK") + "<br>"; text += "sv-SE: " + n.toLocaleString("sv-SE") + "<br>"; text += "ta-IN: " + n.toLocaleString("ta-IN") + "<br>"; text += "ta-LK: " + n.toLocaleString("ta-LK") + "<br>"; text += "th-TH: " + n.toLocaleString("th-TH") + "<br>"; text += "tr-TR: " + n.toLocaleString("tr-TR") + "<br>"; text += "zh-CN: " + n.toLocaleString("zh-CN") + "<br>"; text += "zh-HK: " + n.toLocaleString("zh-HK") + "<br>"; text += "zh-TW: " + n.toLocaleString("zh-TW") + "<br>"; document.getElementById("demo").innerHTML = text; </script> </code> </body> </html>