TypedArray to TypedArray.prototype.toLocaleString()

It returns a string which reprethatents the element of the typedArray.

Example: The code converts the elements of the Uint32Array to localized strings in default, en-US, and Hindi with custom currency formatting (HIR).

Javascript




let geek = new Uint32Array([100, 897, 123, 132, 22]);
 
console.log(geek.toLocaleString());
 
console.log(geek.toLocaleString('en-US'));
 
console.log(geek.toLocaleString('hi',
    { style: 'currency', currency: 'HIR' }));


Output

100,897,123,132,22
100,897,123,132,22
HIR 100.00,HIR 897.00,HIR 123.00,HIR 132.00,HIR 22.00

Supported Browsers:

  • Google Chrome 1 and above
  • Internet Explorer 5.5 and above
  • Firefox 1 and above
  • Apple Safari 1 and above
  • Opera 4 and above
  • Edge 12 and above


JavaScript Object toLocaleString() Method

The Object.prototype.toLocaleString() method returns a local specific string representation of this object using the locale of the environment. Derived objects like an array, number, date, typedarray, and BigInt can override this method.

Syntax:

object.toLocaleString()

Return Value: It returns a string representation of this object.

Objects overriding toLocaleString():

Similar Reads

1. Array to Array.prototype.toLocaleString()

It returns a string representation of this array object....

2. BigInt to BigInt.prototype.toLocaleString()

...

3. Date to Date.prototype.toLocaleString()

It returns a string representation of this BigInt object....

4. Number to Number.prototype.toLocaleString()

...

5. TypedArray to TypedArray.prototype.toLocaleString()

It returns a string representation of this date object....

Contact Us