What is array toSource of JavaScript

In this article, i am going to explain about JavaScript toSource method.
  • 1776

Array  toSource method of JavaScript

The JavaScript toSource method returns one string representing the toSource of the array object.

Syntax of toSource method

array.toSource();

It has no parameter.

Return value of  toSource method

toSource method returns a string representing the source code of the array.

Example of toSource method

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Array toSourceome Method</title>
</head>
<body>
<script type="text/javascript">
   numbers = new Array(1,2,3);
    colors = new Array("Blue","Green","Red",numbers);
    aString = colors.toSource();
    document.write(aString);

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


Output:
 

["Blue", "Green", "Red", [3, 6, 7]]


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

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.