`toString()` 返回一个字符串，表示指定的数组及其元素。

## 语法

    arr.toString()

### 返回值

一个表示指定的数组及其元素的字符串。

## 描述

`Array`对象覆盖了`Object`的 `toString` 方法。对于数组对象，`toString` 方法连接数组并返回一个字符串，其中包含用逗号分隔的每个数组元素。

当一个数组被作为文本值或者进行字符串连接操作时，将会自动调用其 `toString` 方法。

### ECMAScript 5 semantics

从 JavaScript 1.8.5 (Firefox 4) 开始，和 ECMAScript 第5版语义（semantics）一致，`toString()` 方法是通用的，可被用于任何对象。将调用`Object.prototype.toString()`，并返回结果值。

## 规范

Specification | Status | Comment
--- | --- | ---
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented in JavaScript 1.1.
ECMAScript 5.1 (ECMA-262) Array.prototype.toString | Standard |
ECMAScript 2015 (6th Edition, ECMA-262) Array.prototype.toString | Standard |
ECMAScript Latest Draft (ECMA-262) Array.prototype.toString | Draft |

## 浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

Update compatibility data on GitHub

| Desktop | Mobile | Server
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | Safari on iOS | Samsung Internet | Node.js
`toString` | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes

### Legend

Full support
  Full support

## 相关链接

- `Array.prototype.join()`
- `Object.prototype.toSource()`