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.

JavaScript code to show the working of this function:

Code #1:



filter_none

edit
close

play_arrow

link
brightness_4
code

<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


Output:

5,10,15,20,25,30,35

Code #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<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


Output:

0,0,0

Here output is zero because content of the typedArray should be number not string.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.