Array.prototype.toString()
toString() Returns:
string · Updated March 13, 2026 · Array Methods array tostring conversion
ArraytoString() returns a string representation of the array. It converts each element to a string using its own toString() method and joins them with commas.
Syntax
arr.toString()
Parameters
None.
Examples
Basic usage
const fruits = ["apple", "banana", "cherry"];
console.log(fruits.toString());
// "apple,banana,cherry"
With different data types
const mixed = [1, "hello", true, null];
console.log(mixed.toString());
// "1,hello,true,"
Nested arrays
const nested = [1, [2, 3], [4, [5, 6]]];
console.log(nested.toString());
// "1,2,3,4,5,6"
Note that toString() flattens nested arrays into a single comma-separated string.
Common Patterns
Converting to comma-separated list
const tags = ["javascript", "es6", "arrays"];
const list = tags.toString();
console.log(list);
// "javascript,es6,arrays"
With dates
const dates = [new Date(2024, 0, 1), new Date(2024, 11, 25)];
console.log(dates.toString());
// "Mon Jan 01 2024 00:00:00 GMT-0500 (Eastern Standard Time),Wed Dec 25 2024 00:00:00 GMT-0500 (Eastern Standard Time)"
With objects
const objects = [{a: 1}, {b: 2}];
console.log(objects.toString());
// "[object Object],[object Object]"
Objects don’t have a useful string representation by default—use JSON.stringify() or map() to convert them.
vs join()
The main difference between toString() and join() is that join() allows you to specify a custom separator:
const words = ["Hello", "World"];
console.log(words.toString());
// "Hello,World"
console.log(words.join(" "));
// "Hello World"
console.log(words.join(" - "));
// "Hello - World"
Implementation Details
Internally, toString() calls the join() method with no arguments, which defaults to using a comma as the separator. If any element is null or undefined, it is converted to an empty string in the output.