Array.valueOf()

JavaScript1.1+, JScript3.0+, ECMAScript1.0+ NES2+, Nav3+, IE4+, Opera3+ Syntax

							array.valueOf()

Description

The valueOf() method returns the primitive value of the object. In terms of an instance of an Array object, this method returns the array elements separated by commas. If an array contains another array, the contents are flattened when this method is used.

Example

Listing 6.62 creates an Array object of colors and an Array object of numbers. The array of numbers is included in the array of colors. Because the valueOf() method returns the actual elements in the array, "Blue,Green,Red,3,6,7" is written to the browser.

Listing 6.62 Using the valueOf() Method to Return the Value of the Array Object
 <script language="JavaScript"> ...

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.