What is array toString JavaScript

In this article, i will go to explain array toString() in JavaScript.
  • 1787

Array toString() in JavaScript

The JavaScript array toString method converts an array into a string.

Syntax of toString method

array.toString();

It has no parameter.

Return value of  toString  method

tostring method returns a string representing the array.

Example of toString method

<!DOCTYPE html>

<html>

<head>

<title>JavaScript Array toString Method</title>

</head>

<body>

<script type="text/javascript">

var val = new Array("one", "two", "three","four");

var retstr = val.toString();

document.write("Returned string is : " + retstr );

</script>

</body>
</html>


Output:

tostring.jpg

Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.