English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Array toString() Method

 JavaScript Array Object

toString()The method converts the array to a string.

toString()The method joins the array and returns a string containing each array element separated by a comma.

JavaScript automatically calls the method in the following casestoString()Method:

  • The array will be represented as a text value

  • Refer to the array in string concatenation

Syntax:

array.toString()
var months = ["Jan", "Feb", "Mar", "Apr", "May"];
document.getElementById("result").innerHTML = months.toString();
Test and see‹/›

Browser Compatibility

All browsers fully support the toString() method:

Method
toString()YesYesYesYesYes

Technical Details

Return value:String representation of array elements
JavaScript Version:ECMAScript 1

 JavaScript Array Object