JavaScript Array toString() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

Array.prototype.toString() turns an array into a comma-separated string. It is the same as join() with the default comma — and does not mutate the array.

Remember
array.toString()

→ "a,b,c"          (comma, no spaces)
same as join()     (default separator)
read-only

"Hi: " + arr       → calls toString automatically
custom separator?  → use join(" | ")

Syntax

Call array.toString. Start with this line.

JavaScript
array.toString()
CallWhat it does
array.toString()Primary signature.
array.toString(...)Call with the arguments your case needs.

Built into JavaScript. Call toString(...) on an array instance — no import required.

Library declarations
JavaScript
array.toString()

Parameters

ParameterDescription
ArrayRequired. Source values

Return Value

Return ValueDescription
*Comma-separated string

JavaScript Examples

Example 1 — Convert to a Comma-Separated String

Turn a color list into one line of text.

JavaScript
const colors = ["red", "green", "blue", "yellow"];

const text = colors.toString();

console.log(text);
// "red,green,blue,yellow"
Try It Yourself

How It Works

  1. Start with four strings. Each element is already text.
  2. Call toString(). Elements are joined with commas.
  3. No spaces after commas. Result is red,green,blue,yellow.
  4. Array unchanged. colors still has four items.

Example 2 — Implicit toString() in Concatenation

JavaScript calls toString() when you mix an array with a string.

JavaScript
const days = ["Mon", "Tue", "Wed"];

console.log("Days: " + days);
// "Days: Mon,Tue,Wed"

console.log(String(days));
// "Mon,Tue,Wed"
Try It Yourself

How It Works

  1. String on the left. "Days: " + days needs a string result.
  2. Coercion runs. The array is converted via toString().
  3. String(days) is explicit. Same comma list without a prefix.
  4. Know the default. You always get commas — not spaces or pipes.

Example 3 — toString() vs join()

Need readable spacing? Use join with a custom separator.

JavaScript
const colors = ["red", "green", "blue"];

console.log(colors.toString());
// "red,green,blue"

console.log(colors.join(" | "));
// "red | green | blue"
Try It Yourself

How It Works

  1. toString is fixed. Always commas, no options.
  2. join is flexible. Pass any separator string.
  3. Same default. join() with no args matches toString().
  4. Pick by need. Quick dump → toString; pretty text → join.

Browser & Runtime Support

Array.prototype.toString() has been available since ES3 and is one of the most widely supported JavaScript methods.

✓ Baseline · ES3

Array.prototype.toString()

Supported in every browser and Node.js version—including very old environments. Behavior is identical across platforms.

100% Universal support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Array.toString() Universal

Bottom line: Safe everywhere. Remember its limits with objects and locale-sensitive numbers.

Frequently Asked Questions

toString() converts an array to a comma-separated string by converting each element and joining with commas. It returns a string and does not mutate the array.
No. It only reads the array and returns a new string. The original array is unchanged.
Array.toString() is equivalent to join() with no arguments (comma separator). Use join(' | ') when you need a custom delimiter.
When an array is coerced to a string—string concatenation ('Values: ' + arr), String(arr), or many template cases—JavaScript calls the array's toString method.
Plain objects convert with Object.prototype.toString. Use JSON.stringify, map, or a custom formatter for readable object output.
Array.toString() has been available since ES3 and works in every browser and Node.js environment.

Next: unshift()

Learn how to add one or more elements at the beginning of an array.

unshift() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful