The toString method in JavaScript is employed to transform the elements of a specified array into a string format, with each element separated by a comma (",").
Syntax:
Example
array.toString()
Parameters:
No parameters.
Return value:
It provides a string that denotes the components of the array.
Browser Support:
| Chrome | Yes |
|---|---|
| Safari | Yes |
| Firefox | Yes |
| Opera | Yes |
Example
JavaScript TypedArray toString Method
Example
<script>
//JavaScript to illustrate toString() method
var A = "Example";
var B = "Core Java";
// C is an array containing elements of above variables
var C = [A,B];
// Calling toString() method
var isMore= C.toString();
// Printing string
document.write(isMore);
// expected output:Example,Core Java
</script>
Output:
Output
Example,Core Java