toString()  Array  instance method JS Home  <<  JS Reference  <<  Array  <<  toString()

Description

Returns a string composed of concatenated array elements delimited by commas.

This method overrides the toString() method of Object.

Syntax

Signature Description
anArray.toString()Returns a string composed of concatenated array elements delimited by commas.

Parameters

None.

Examples

The code below creates an array then a string from the initial array.


// Create an array of days of the week.
var week = ['Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun'];
/*
 Create a string from week array. 
 var dayString = 'Mon,Tues,Wed,Thurs,Fri,Sat,Sun'.
 /*
var dayString = week.toString();
alert(dayString);

Press the button below to action the above code:

Related Tutorials

JavaScript Intermediate Tutorials - Lesson 1 - Arrays

JavaScript Basics

JavaScript Basics

JavaScript Intermediate

JavaScript Intermediate

JavaScript Advanced

JavaScript Advanced

JavaScript Reference

JavaScript Entities

Globals

Array

Class Properties
prototype
Instance Properties
constructor
length
Class Methods
None.
Instance Methods Getters
concat()
join()
slice()
toString()
Instance Methods Setters
pop()
push()
reverse()
shift()
sort()
splice()
unshift()

Statements

Operators