JavaScript object valueOf() method
- Föregående sida toString()
- Nästa sida values()
- Gå tillbaka till föregående nivå JavaScript objekt referenshandbok
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
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 the object. If an object does not have an original value, the valueOf() returns the object itself. |
Browser support
valueOf()
Is ECMAScript1 (ES1) feature.
All modern browsers support ES1 (JavaScript 1997):
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Stöd | Stöd | Stöd | Stöd | Stöd | Stöd |
Relaterade sidor
- Föregående sida toString()
- Nästa sida values()
- Gå tillbaka till föregående nivå JavaScript objekt referenshandbok