Favorites

JavaScript Array.prototype.toString() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Array.prototype.toString()
JavaScript Array Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The toString() method returns a string of an array's elements separated by commas.

Description

The toString() method returns the elements joined by commas, the same as join() with no argument. JavaScript calls it automatically when an array is used where a string is expected, such as in string concatenation. For a readable representation of nested data, JSON.stringify() is usually more useful.

For arrays, toString() is equivalent to join(','): null and undefined elements become empty strings and nested arrays are flattened into the same comma-separated list, which loses their structure. Objects inside become "[object Object]".

You'll mostly encounter it indirectly, when an array is concatenated with a string or put inside a template literal, or when it's used as an object key. When you need a specific separator, call join(), and when you need to keep the data's structure, use JSON.stringify().

Syntax

array.toString()

Return Value

A string of the elements separated by commas.

Example

console.log([1, 2, 'a'].toString());
console.log('Items: ' + ['x', 'y']);
console.log([1, [2, 3]].toString());

Browser Support

The following information will show you the current browser support for the Array.prototype.toString() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee