This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

toString

Summary

Returns a string representation of an array.

Syntax

toString()

Return Value

The string representation of the array.

Examples

The following example illustrates the use of the toString method with an array.

var arr = [1, 2, 3, 4];
 var s = arr.toString();
 document.write(s);

 // Output: 1,2,3,4

Remarks

The elements of an Array are converted to strings. The resulting strings are concatenated and separated by commas.

See also

Specification

15.4.4.2 Array.prototype.toString ( ) ECMAScript® Language Specification Standard ECMA-262 5.1 Edition / June 2011

Attributions

  • Microsoft Developer Network: Article