Latest web development tutorials

JavaScript toString () method

Array Object Reference Manual JavaScript Array Object

Examples

The array is converted to a string:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.toString();

fruits will output:

Banana,Orange,Apple,Mango

try it"

Definition and Usage

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

Note: separated by commas between array elements.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support toString ().


grammar

array.toString()

Return Value

Type 描述
String 数组的所有值用逗号隔开

technical details

JavaScript version: 1.1


Array Object Reference Manual JavaScript Array Object