Skip to content
Related Articles

Related Articles

TypeScript | Array toString() Method
  • Last Updated : 18 Jun, 2020

The Array.toString() is an inbuilt TypeScript function which is used to get a string representing the source code of the specified array and its elements. 
Syntax:

array.toString()

Parameter: This method does not accept any parameter. 

Return Value: This method returns the string representing the array. 

Below example illustrate the  String toString() method in TypeScriptJS:

Example 1: 



JavaScript

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
    // Driver code
    var arr = [ 11, 89, 23, 7, 98 ]; 
  
    // use of toString() method 
    var tring= arr.toString();
           
    // printing
    console.log(tring);
</script>

chevron_right


Output: 

11,89,23,7,98

Example 2: 

JavaScript

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
    // Driver code
    var arr = ["G", "e", "e", "k", "s", "f", "o"
               "r", "g", "e", "e", "k", "s"]; 
    var val;
   
    // use of toString() method 
    val = arr.toString();
    console.log( val );
</script>

chevron_right


Output: 

G,e,e,k,s,f,o,r,g,e,e,k,s

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :