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

Basic useTry it yourself
console.log([1, 2, 3].toString(), String(["a", ["b", "c"]]));

Output

1,2,3 a,b,c
Automatic conversionTry it yourself
console.log("Items: " + ["tea", "cake"]);

Output

Items: tea,cake

Version history

VersionChange
JavaScript ES1Added