TypeScript Array toString() Method
Last Updated :
03 Jan, 2023
The Array.toString() is an inbuilt TypeScript function that 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
<script>
var arr = [ 11, 89, 23, 7, 98 ];
var string= arr.toString();
console.log(string);
</script>
|
Output:
11,89,23,7,98
Example 2:
JavaScript
<script>
var arr = [ "G" , "e" , "e" , "k" , "s" , "f" , "o" ,
"r" , "g" , "e" , "e" , "k" , "s" ];
var val;
val = arr.toString();
console.log( val );
</script>
|
Output:
G,e,e,k,s,f,o,r,g,e,e,k,s
Share your thoughts in the comments
Please Login to comment...