JavaScript | typedArray.toString() with Examples
The typedArray.toString() is an inbuilt function in JavaScript which is used to convert the contents of the tyepdArray to string.
Syntax:
typedarray.toString()
Parameters: This function does not accept any parameter.
Return value: It returns a string which represents the elements of the typedArray.
Code #1:
<script> // Constructing a new typedArray Uint8Array() object const A = new Uint8Array([5, 10, 15, 20, 25, 30, 35]); // Converting the elements of typedArray // object into string const B = A.toString(); // Printing converted string document.write(B); </script> |
chevron_right
filter_none
Output:
5,10,15,20,25,30,35
Code #2:
<script> // Constructing a new typedArray Uint8Array() object const A = new Uint8Array([ "gfg" , "CSE" , "GeeksForGeeks" ]); // Converting the elements of typedArray // object into string const B = A.toString(); // Printing converted string document.write(B); </script> |
chevron_right
filter_none
Output:
0,0,0
Here output is zero because content of the typedArray should be number not string.