Skip to content

JavaScript array to string | toString method()

  • by

Using the toString() method you can convert the array to a string in JavaScript. This method returns a string representing the specified array and its elements.

array.toString()

Note: the toString method can’t be used on an array of objects because it will return [object Object] instead of the actual values.

Convert array to string in JavaScript

Simple example code print array as a string in the console.

  <!DOCTYPE html>
  <html>
  <head>

    <script>
      const array1 = [100, 200, 'AAA', 'BBB'];

      console.log(array1.toString());
    </script>

  </head>
  </html>

Output:

JavaScript array to string

Do comment if you have any doubts or suggestions on this JS array topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading