1) 1 == 1 returns true
2) 3 < 1 returns false
3) 5 >= 4 returns true
4) "the" != "he" returns true
5) 4 == "4" returns true1
6) 4 == "a4" returns an error message2
7) true == 1 returns true3
8) true == 0 returns false
9) a == b returns false if a = new Array(1,2) and b = new Array(1,2)4Notes:
- If one value is a number and the other is a string, convert the string
to a number and try the comparison again, using the converted value.
- When comparing string and numeric values, if the string value begins with nonnumeric
characters, JavaScript will generate an error
- If either value is true, convert
it to 1 and try the comparison
again. If either value is false,
convert it to 0 and try the
comparison again.
- Objects, arrays, and functions are compared by reference. This means that two variables
are equal only if they refer to the same object.
Rule:
If both refer to the same Object, Array, or Function, they are equal. If
they refer to different Objects (or Arrays or Functions) they are not
equal, even if both Objects could be converted to the same primitive
value.
|