CodesJava

Easy learning with example program codes

TypedArray join() JavaScript

The Javascript TypedArray join() method combines all the elements of an Array into a string. All elements will be separated by the specified separator. Default separator is comma(,).

Syntax:

array.join(separator)  

Parameters:
separator: It represents the separator to which all elements will be separated. It is optional

Returns:
It returns a string which combines all the elements of an Array.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">   
var Jewels = ["DIAMOND","GOLD","PLATINUM","SILVER"];
document.write(Jewels.join('.'));   
</script>
</body>
</html>

Output:

DIAMOND.GOLD.PLATINUM.SILVER

Example 2:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript"> 
const testArray = new Uint8Array([34, 12, 56, 12, 89]);
 
document.write(testArray.join());
document.write("</br>");
 
document.write(testArray.join(''));
document.write("</br>");
 
document.write(testArray.join('-'));
 
</script>
</body>
</html>

Output:

34,12,56,12,89
3412561289
34-12-56-12-89
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status