Open In App

JavaScript typedArray.toString() with Examples

Last Updated : 22 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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>
    // 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
    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>
    // 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
    console.log(B);
</script>


Output:

0,0,0

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads