Skip to content
Related Articles

Related Articles

JavaScript | typedArray.toString() with Examples
  • Last Updated : 14 Feb, 2019

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:






<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>


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>


Output:

0,0,0

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

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :