JavaScript typedArray.toString() with Examples
The Javascript typedArray.toString() is an inbuilt function in JavaScript that is used to convert the contents of the tyepdArray into a string.
Syntax:
typedarray.toString()
Parameters: This function does not accept any parameter.
Return value: It returns a string that represents the elements of the typedArray.
JavaScript examples to show the working of this function:
Example 1: In this example, we will convert an array of integer values to a string using typedarray.toString() function.
javascript
<script>
const A = new Uint8Array([5, 10, 15, 20, 25, 30, 35]);
const B = A.toString();
console.log(B);
</script>
|
Output:
5,10,15,20,25,30,35
Example 2: Here output is zero because content of the typedArray should be number not string.
javascript
<script>
const A = new Uint8Array([ "gfg" , "CSE" , "GeeksForGeeks" ]);
const B = A.toString();
console.log(B);
</script>
|
Output:
0,0,0
Last Updated :
22 Dec, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...