Copyright © tutorialspoint.com

Javascript Array toString() Method

previous next

Advertisements


Description:

Javascript array toString() method returns a string representing the source code of the specified array and its elements.

Syntax:

array.toString();

Here is the detail of parameters:

Return Value:

Returns a string representing the array.

Example:

<html>
<head>
<title>JavaScript Array toString Method</title>
</head>
<body>
<script type="text/javascript">
var arr = new Array("orange", "mango", "banana", "sugar");

var str = arr.toString();
document.write("Returned string is : " + str );

</script>
</body>
</html>

This will produce following result:

Returned string is : orange,mango,banana,sugar 

To understand it in better way you can Try it yourself.


previous next

Copyright © tutorialspoint.com