Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript toString() Method

JavaScript toString() Method

Array Object Reference JavaScript Array object

Example

Converts an array to a string:

var fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.toString();

fruitsWill output:

Banana,Orange,Apple,Mango

Try it »


Definition and Usage

The toString() method converts an array to a string and returns the result.

Note: The elements in the array are separated by commas.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support toString().


Syntax

array

.toString()

Return Value

Type Description
String All values of the array are separated by commas

Technical Details

JavaScript version: 1.1

Array Object Reference JavaScript Array object