Skip to content
Related Articles

Related Articles

Improve Article
JavaScript | typedArray.toLocaleString() Method
  • Last Updated : 02 Apr, 2020

The typedArray.toLocaleString() method is used to convert the elements to strings and are separated by a locale-specific string.

Syntax:

typedarray.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 which represents the element of the typedArray.

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



Example 1:




var 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"

Example 2:




var A = " GeeksforGeeks ";  
var B = " JavaScript ";
var C = " Array.prototype.toLocaleString() ";
var D = [A, B, C];   
var result= D.toLocaleString();   
console.log(result);  

Output:

 " GeeksforGeeks, JavaScript, Array.prototype.toLocaleString() "

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

  • Google Chrome
  • Firefox
  • IE
  • Opera
  • Safari
  • Edge
My Personal Notes arrow_drop_up
Recommended Articles
Page :