Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript valueOf() Method

JavaScript valueOf() Method

Array Object Reference JavaScript Array object

Example

valueOf() is the default method of the Array object.

var fruits = ["Banana", "Orange", "Apple", "Mango"];

var v=fruits.valueOf();

 *fruits.valueOf()* and fruitsreturn the same value.

vThe output is:

Banana,Orange,Apple,Mango

Try it »


Definition and Usage

The valueOf() method returns the primitive value of the Array object.

This primitive value is inherited by all objects derived from the Array object.

The valueOf() method is usually called automatically by JavaScript in the background and does not appear explicitly in the code.

Note: The valueOf() method does not change the original array.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support valueOf().


Syntax

array

.valueOf()

Return Value

Type Description
Array valueOf() returns the array value

Array Object Reference JavaScript Array object