Array toString() Method - Javascript Array

Javascript examples for Array:toString

Description

The toString() method converts an array into a String and returns the result.

Parameters

None

Return Value:

A String, representing the values of the array, separated by a comma

The following code shows how to Convert an array to a string:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from  w w  w  .j a  va  2  s.  co  m
    var fruits = ["a","b","c","d","e"];
    fruits.toString();
    document.getElementById("demo").innerHTML = fruits;
}
</script>

</body>
</html>

Related Tutorials