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

BigInt.prototype.toLocaleString() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

BigInt.prototype.toLocaleString()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2020 9.

BigInt toLocaleString() BigInt . Intl.NumberFormat API Intl.NumberFormat .

toLocaleString . NumberFormat format() . format Intl.NumberFormat format() .

In this article

const bigint = 123456789123456789n;

// German uses period for thousands
console.log(bigint.toLocaleString("de-DE"));
// Expected output: "123.456.789.123.456.789"

// Request a currency format
console.log(
  bigint.toLocaleString("de-DE", { style: "currency", currency: "EUR" }),
);
// Expected output: "123.456.789.123.456.789,00 "

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

locales and options .

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

locales Optional

BCP 47 . Intl.NumberFormat() locales .

Intl.NumberFormat .

options Optional

. Intl.NumberFormat() options .

Intl.NumberFormat .

Intl.NumberFormat() .

BigInt .

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

: toLocaleString() . , , . toLocaleString() .

toLocaleString()

locale .

js
const bigint = 3500n;

console.log(bigint.toLocaleString());
// "3,500" U.S English  

locales options

locales locales API . toLocaleString() . locales options Intl , .

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

locales

. locales ( ) .

js
const bigint = 123456789123456789n;

//     .
console.log(bigint.toLocaleString("de-DE"));
// 123.456.789.123.456.789

//       .
console.log(bigint.toLocaleString("ar-EG"));
// 

//   /lakh/crore   .
console.log(bigint.toLocaleString("en-IN"));
// 1,23,45,67,89,12,34,56,789

// nu     .(:  10)
console.log(bigint.toLocaleString("zh-Hans-CN-u-nu-hanidec"));
// ,,,,,

//           (  ) .
console.log(bigint.toLocaleString(["ban", "id"]));
// 123.456.789.123.456.789

options

toLocaleString() options .

js
const bigint = 123456789123456789n;

//   
console.log(
  bigint.toLocaleString("de-DE", { style: "currency", currency: "EUR" }),
);
// 123.456.789.123.456.789,00 

//     
console.log(
  bigint.toLocaleString("ja-JP", { style: "currency", currency: "JPY" }),
);
// 123,456,789,123,456,789

//  3 
console.log(bigint.toLocaleString("en-IN", { maximumSignificantDigits: 3 }));
// 1,23,00,00,00,00,00,00,000

Specification
ECMAScript 2027 Internationalization API Specification
# sup-bigint.prototype.tolocalestring


Web Proxy Viewer  |  New URL  |  Original Page