JavaScript Object valueOf() Method
- Previous Page toString()
- Next Page values()
- Go to the Previous Level JavaScript Object Reference Manual
Definition and usage
valueOf()
the method returns the original value of the object.
If an object does not have an original value, then valueOf()
Returns the object itself.
valueOf()
The method does not change the original object.
Note:fruits.valueOf()
Returns the same as fruits
The same value.
Instance
Example 1
Get the value of fruits:
const fruits = ["Banana", "Orange", "Apple", "Mango"]; const myArray = fruits.valueOf();
Example 2
The return value of fruits.valueOf() is the same as fruits:
const fruits = ["Banana", "Orange", "Apple", "Mango"]; const myArray = fruits;
Syntax
object.valueOf()
Parameter
No parameters.
Return value
Type | Description |
---|---|
Object |
The original value of an object. If an object does not have an original value, the valueOf() method returns the object itself. |
Browser support
valueOf()
It is ECMAScript1 (ES1) feature.
All modern browsers support ES1 (JavaScript 1997):
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
Related Pages
- Previous Page toString()
- Next Page values()
- Go to the Previous Level JavaScript Object Reference Manual