JavaScript valueOf() Method

Array Object 参考手册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()andfruitsThe return value is the same.

vThe output result is:

Banana,Orange,Apple,Mango

Try it Yourself »


Definition and Usage

The valueOf() method returns the primitive value of an 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 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 参考手册JavaScript Array Object

Other Extensions