Equality operators are generally used for comparing primitive values.
If they are used for comparing objects, the objects are converted to primitives and then tested. This may not be the test you are trying to accomplish.
Imagine two objects, each distinct from one another but containing the same value in the properties that are yielded by the toString() or valueOf() methods. They are different objects but they will test true for equality.
The identity operators provide a way to test whether they are the same object or not.
There are two identity operators:
=== Identically equal to
!=== Not identically equal to
You can use these in relational expressions in much the same way as you would the equality operators but remember that you are testing references to objects not values.
Prev | Home | Next |
Identifier resolution | Up | ids |
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. |