[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString [Back]  [Original]

Number.prototype.toLocaleString() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Number.prototype.toLocaleString()

Baseline

20157

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));
// : " "

js
toLocaleString()
toLocaleString(locales)
toLocaleString(locales, options)

locales options

Intl.NumberFormat API Intl.NumberFormat() Intl.NumberFormat

locales

BCP 47 Intl.NumberFormat() locales

Intl.NumberFormat

options

Intl.NumberFormat() options

Intl.NumberFormat

Intl.NumberFormat()

Intl.NumberFormat new Intl.NumberFormat(locales, options).format(number)

: toLocaleString() toLocaleString()

toLocaleString()

locale

js
const number = 3500;

console.log(number.toLocaleString()); //  "3,500" 

locales options

locales options API toLocaleString() locales options Intl API

js
function toLocaleStringSupportsLocales() {
  return (
    typeof Intl === "object" &&
    !!Intl &&
    typeof Intl.NumberFormat === "function"
  );
}

locales

locales

js
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

options

toLocaleString() options

js
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

//  3 
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"

ECMAScript 2027 LanguageSpecification
# sec-number.prototype.tolocalestring
ECMAScript 2027 Internationalization API Specification
# sup-number.prototype.tolocalestring


Web Proxy Viewer  |  New URL  |  Original Page