|
December 5, 1999 Identity Operators Tips: December 1999
Yehuda Shiran, Ph.D.
|
|
JavaScript's standard equality operators (== and !=) check if two expressions are equal (or not equal). If the two operands are not of the same type, JavaScript attempts to convert the operands to an appropriate type for the comparison. Values are considered equal if they are identical strings, numerically equivalent numbers, the same object, identical Boolean values, or (if different types) they can be coerced into one of these situations. Here are a few more rules:NaN is not equal to anything including itself. null equals both null and undefined.
Every other comparison is considered unequal. JavaScript's identity (strict equality) operators (
The problem with JavaScript's identity operators is that they are only supported by some browsers:
IE = Microsoft Internet Explorer N = Netscape Navigator (standalone) C = Netscape Communicator
We can use the
People who read this tip also read these tips: Look for similar tips by subject: |