JavaScript (ES2026) reference · Array Methods
JavaScript Array toString() Method
Return a string of the array's elements separated by commas. Called automatically when an array is used as text.
JavaScript (ES2026) Since ES1
Syntax
array.toString()
Return value
A string.
Examples
console.log([1, 2, 3].toString(), String(["a", ["b", "c"]]));
Output
1,2,3 a,b,c
console.log("Items: " + ["tea", "cake"]);
Output
Items: tea,cake
Version history
| Version | Change |
|---|---|
| JavaScript ES1 | Added |
Related
array.join()· Join all elements into one string, separated by commas or by a separator you choose.- JavaScript Arrays · tutorial
- JavaScript Array Methods · tutorial