Array.toSource()

JavaScript1.3+, JScript3.0+, ECMAScript2.0+ (proposed) Nav4.06+, IE4+ Syntax

							array.toSource()

Description

The toSource() method returns one string representing the source of the Array object. The string that is returned contains all the elements in the array separated with commas. The entire string is enclosed with brackets ([]) to show it is an array. If another array is contained within an array, its contents are also part of the string with its own set of brackets.

Example

Listing 6.59 creates an Array object of colors and an Array object of numbers. The array of numbers is included in the array of colors. The toSource() method is then applied to the Array object to return the source string.

 ["Blue", "Green", "Red", ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.