How to represent the source code of an object with JavaScript Arrays?

HTMLJavascriptProgramming Scripts

JavaScript array toSource() method returns a string representing the source code of the array. This method is supported by Mozilla.

Example

You can try to run the following code to learn how to represent the source code of an object with JavaScript Arrays −

<html>
   <head>
      <title>JavaScript Array toSource Method</title>
   </head>
   <body>
      <script>
         var arr = new Array("football", "baseball", "volleyball", "cricket");
       
         var str = arr.toSource();
         document.write("Returned string is : " + str );
      </script>
   </body>
</html>
raja
Updated on 23-Jun-2020 08:28:59

Advertisements