JavaScript Array.prototype.toString()

JavaScript Array.prototype.toString()
0

#1

The JavaScript array method .toString() is used to convert an array into a single string, with each element joined by a comma. There are no parameters for the method.

Syntax

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

Usage

var str1 = [1, 2, 3, 4, 5].toString();  // str1 = '1,2,3,4,5';
var str2 = ['1', '2', '3', '4'].toString();  // str2 = '1,2,3,4';
var str3 = ['Free', 'Code', 'Camp'].toString();  // str3 = 'Free,Code,Camp';
var str4 = ['phone', '555-6726'].toString();   // str4 = 'phone,555-6726';
var str5 = ['August', 'September', 'October'].toString();  // str5 = 'August,September,October';
var str6 = ['Words', 'and', 3, 4].toString();  // str6 = 'Words,and,3,4';

Source: MDN


#2