toString Method (Array)

Returns a string representation of an array.

Syntax


array.toString()  

Parameters

array
Required. The array to represent as a string.

Return Value

The string representation of the array.

Remarks

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

Example

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  

Requirements

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.