Next page | Contents page |

Equality (==) and identity (===)

Identity

To check that the contents of the boxes (values or references) are exactly the same, use the stricter a === b.

This requires a and b to be of the same type.

It is false if both a and b are NaN

It is false if one is null and the other is undefined

Equality

Equality, a == b, allows the types to be different if, after type conversion (eg, string or boolean to number), the results are then the same.

It is true if both a and b are NaN

It is true if one is null and the other is undefined

Next page | Contents page |