JavaScript valueOf() Method
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





All major browsers support valueOf().
Syntax
array
.valueOf()
Return Value
| Type | Description |
|---|---|
| Array | valueOf() returns the array value |
JavaScript Array object