toString() method returns one string that contains all the elements in the array separated with commas.
The toString() method is used to convert an array to a string when the array is used in string context.
In this method we cannot modify the seperator. To change seperator go to join().
The following example shows JavaScript to Use an Array's toString() Method.
<html>
<script language="JavaScript">
colors = new Array("Blue","Green","Red");
document.write(colors.toString());
</script>
</html>
Output is Blue,Green,Red
No comments:
Post a Comment