Skip to content
Related Articles

Related Articles

Improve Article

JavaScript | typedArray.toString() with Examples

  • Last Updated : 14 Feb, 2019
Geek Week

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.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it’s lowest price ever!




My Personal Notes arrow_drop_up
Recommended Articles
Page :