- Object – object reference
- String – immutable, 16-bit USC-2
- Boolean –
- Number – only 64-bit floating point, IEEE 754 (double)
null– empty object reference
undefined– unassigned variables and function arguments, missing object properties
Boolean evaluation of values using
Values that are interpreted as
""– the empty string
0– the number 0
NaN– not a number, result of undefined math operation
All other values and objects are interpreted as
Working with comparison operators
!= operators will do implicit type conversion of it’s arguments to match their type. Since the
undefined values are both equal with these operators, errors can occur when a missing object property is used in a null-comparison.
By using the
!== operators, no implicit type conversion will be done. The values
undefined are not equal using these operators. These operators can be used to check against missing properties and unassigned arguments among other.
!== for null-comparison tests. It might be that an undefined-comparison should have been used instead (or both). Failure to recognise these cases can introduce hard-to-catch errors.