As a general rule, the valueOf() method for an object simply returns the this property of the object itself. However, the object may be a wrapper for a host object some kind. It may therefore have been created by invoking the Object constructor. In that case, the host object should be returned in an ECMA-compliant implementation.
Implementations may choose to return the this property of an object or some other value if they choose.
The result of this method will be implementation- and object-dependant. The native core objects are well defined and will return predictable value types. Generally these will be defined by ECMA or W3C standards. It is up to the hosting environment to provide the valueOf() interface to its own suite of objects.
See also: | Cast operator, Object.prototype, valueOf() |
ECMA 262 edition 2 - section - 15.2.2.1
ECMA 262 edition 2 - section - 15.2.4.3
ECMA 262 edition 3 - section - 15.2.4.4
Prev | Home | Next |
Object.unwatch() | Up | Object.watch() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |