valueOf()
Object
instance method getterS2C Home
« Globals « Object « valueOf()
Description
Returns the primitive value of an object.
- Automatically invoked when an object is called and a primitive value is expected.
- The
Object.valueOf()
method is inherited by allObject
descendants. - Unless overridden by a custom object
valueOf()
returns[object Object]
.
Syntax
Signature | Description |
---|---|
anObject.valueOf() | Returns the primitive value of an object. |
Parameters
None.
Examples
The code below creates an object and displays it.
// Create an object.
anObject = new Object();
alert(anObject.valueOf() + ' anObject is an instance of Object.');
Related Tutorials
JavaScript Basic Tutorials - Lesson 7 - Objects