HTML and CSS Reference
In-Depth Information
There are numerous inconsistencies in the examples above, and again, these are often bugs
rather than features. Null should not be considered equal to undefined , despite the fact they
are both falsey values they represent very different data-types and meanings.
Fortunately, JavaScript contains an alternative pair of equality operators:
===
!==
These compare variables based on both their value and their data type, and therefore
provide more expected results:
> null === undefined
false
> 5 === "5"
false
> "true" === true
false
> "1" === true
false
It is best practice to always use these equality operators unless you consciously want to
compare two values you know have different data types.
//
If you want to know whether any value is true or false in a Boolean sense, you
can print it out by prepending !! to it. A single ! will negate a Boolean value,
 
Search WWH ::




Custom Search