CodesJava

Easy learning with example program codes

TypedArray toLocaleString() JavaScript

The Javascript TypedArray toLocaleString() method transforms the elements of an array into a locale specific string. All elements of the array will be separated by comma (,).

Syntax:

array.toLocaleString() 

Parameters:
total: It represents previously returned value of the function.
currentValue: It represents the index position of current element.
index: It represents the index position of current element.
arr: It represents the array.
thisValue: It represents this argument for the function.

Returns:
It returns the string.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script>  
var num = ["HELLO",32,34,"WORLD",83];    
document.write(num.toLocaleString());  
</script>
</body>
</html>

Output:

HELLO,32,34,WORLD,83

Example 2:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript"> 
var uint = new Uint32Array([343, 34, 12, 45, 6767]);
 
document.write(uint.toLocaleString());
document.write("</br>");
document.write(uint.toLocaleString('en-US'));
document.write("</br>");
document.write(uint.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' }));
 
</script>
</body>
</html>

Output:

343,34,12,45,6,767
343,34,12,45,6,767343,¥34,¥12,¥45,¥6,767
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status