| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.
toLocaleString() Number . Intl.NumberFormat API Intl.NumberFormat .
toLocaleString . , Intl.NumberFormat format() . NumberFormat , format .
function eArabic(x) {
return x.toLocaleString("ar-EG");
}
console.log(eArabic(123456.789));
// : ""
console.log(eArabic("123456.789"));
// : "123456.789"
console.log(eArabic(NaN));
// : " "
toLocaleString()
toLocaleString(locales)
toLocaleString(locales, options)
locales options .
Intl.NumberFormat API , Intl.NumberFormat() . Intl.NumberFormat , .
locales OptionalBCP 47 , Intl.NumberFormat() locales .
Intl.NumberFormat , .
options Optional , Intl.NumberFormat() options .
Intl.NumberFormat .
.
Intl.NumberFormat new Intl.NumberFormat(locales, options).format(number) .
:
toLocaleString() . , . . . , . toLocaleString() .
locale , .
const number = 3500;
console.log(number.toLocaleString()); // "3,500"
locales options . API , . , toLocaleString() , . locales options Intl API . .
function toLocaleStringSupportsLocales() {
return (
typeof Intl === "object" &&
!!Intl &&
typeof Intl.NumberFormat === "function"
);
}
.
,
locales .
const number = 123456.789;
//
console.log(number.toLocaleString("de-DE"));
// 123.456,789
//
console.log(number.toLocaleString("ar-EG"));
//
// /()/()
console.log(number.toLocaleString("en-IN"));
// 1,23,456.789
// nu . :
console.log(number.toLocaleString("zh-Hans-CN-u-nu-hanidec"));
// ,.
// ,
// , .
console.log(number.toLocaleString(["ban", "id"]));
// 123.456,789
toLocaleString() options .
const number = 123456.789;
//
console.log(
number.toLocaleString("de-DE", { style: "currency", currency: "EUR" }),
);
// 123.456,79
// .
console.log(
number.toLocaleString("ja-JP", { style: "currency", currency: "JPY" }),
);
// 123,457
//
console.log(number.toLocaleString("en-IN", { maximumSignificantDigits: 3 }));
// 1,23,000
//
const num = 30000.65;
console.log(
num.toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}),
);
// "30,000.65"
// "30.000,65"
// "30 000.65"
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-number.prototype.tolocalestring |
| ECMAScript 2027 Internationalization API Specification # sup-number.prototype.tolocalestring |
This page was last modified on 2025 6 29 by MDN contributors.
NumberObject/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |