JavaScript | BigInt.prototype.toLocaleString() Method

The BigInt.prototype.toLocaleString() method is an inbuilt method in JavaScript which is used to return a string with a language-sensitive representation of this BigInt.

Syntax:

bigIntObj.toLocaleString(locales, options)

Parameters: This method accept two parameters as mentioned above and described below:

  • locales: This parameter holds the value of locale.
  • options: It is an optional parameter.

Return value: This method returns a string with a language-sensitive representation of the given BigInt.

Below examples illustrate the BigInt.prototype.toLocaleString() method in JavaScript:



Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

let geekvar = 45334n;
console.log(geekvar.toLocaleString());
  
geekvar =78753456789123456789n;
console.log(geekvar.toLocaleString('de-DE'));
console.log(geekvar.toLocaleString('de-DE',
    { style: 'currency', currency: 'EUR' }));
console.log(geekvar.toLocaleString('hi'));

chevron_right


Output:

"45, 334"
"78.753.456.789.123.456.789"
"78.753.456.789.123.456.789, 00 €"
"7, 87, 53, 45, 67, 89, 12, 34, 56, 789"

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

let geekvar =78753456789123456789n;
  
console.log(geekvar.toLocaleString('ar-EG'));
console.log(geekvar.toLocaleString('en-IN',
        { maximumSignificantDigits: 3 }));
console.log(geekvar.toLocaleString('zh-Hans-CN-u-nu-hanidec'));
console.log(geekvar.toLocaleString(['ban', 'id']));

chevron_right


Output:

Supported Browsers: The browsers supported by BigInt.prototype.toLocaleString() method are listed below:

  • Google Chrome
  • Firefox
  • Opera
  • Safari
  • Edge

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.