| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/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 ..
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));
// Expected output: ""
console.log(eArabic("123456.789"));
// Expected output: "123456.789"
console.log(eArabic(NaN));
// Expected output: " "
toLocaleString()
toLocaleString(locales)
toLocaleString(locales, options)
locales options , , .
, Intl.NumberFormat API, Intl.NumberFormat(). Intl.NumberFormat , .
locales BCP 47 . locales `Intl.NumberFormat().
Intl.NumberFormat .
options . options Intl.NumberFormat().
Intl.NumberFormat .
, .
Intl.NumberFormat new Intl.NumberFormat(locales, options).format(number).
:
, toLocaleString(), . , . toLocaleString() .
toLocaleString(), .
var number = 3500;
console.log(number.toLocaleString()); // '3,500' U.S. English
locales options locales options . toLocaleString() , , . , locales options, Intl API, :
function toLocaleStringSupportsLocales() {
return (
typeof Intl === "object" &&
!!Intl &&
typeof Intl.DateTimeFormat === "function"
);
}
locales . , , , (, , ) locales:
var number = 123456.789;
// ,
console.log(number.toLocaleString("de-DE"));
// 123.456,789
// ,
console.log(number.toLocaleString("ru-RU"));
// 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
options, toLocaleString(), options:
var number = 123456.789;
//
console.log(
number.toLocaleString("de-DE", { style: "currency", currency: "EUR" }),
);
// 123.456,79
console.log(
number.toLocaleString("ru-RU", { style: "currency", currency: "RUB" }),
);
// 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 24 . 2025 . 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 |