English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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
array.toString()
var months = ["Jan", "Feb", "Mar", "Apr", "May"]; document.getElementById("result").innerHTML = months.toString();Test and see‹/›
All browsers fully support the toString() method:
Method | |||||
toString() | Yes | Yes | Yes | Yes | Yes |
Return value: | String representation of array elements |
---|---|
JavaScript Version: | ECMAScript 1 |