TodayILearned - 2023-07-04
Posted on:July 5, 2023 | at 02:37 AM
NaN === NaN
- The only value/data type that does not return ‘true’ during equality comparison
- If you want to check whether a variable’s value is NaN, use
isNaN() (e.g. isNaN(10)).
0 === -0 and 0 == -0
Object.is()
- Alternatively,
Object.is() is a method that determines whether two values are the same value
Object.is(NaN, Nan) will return true
- Conversely,
Object.is(-0, +0) will return false
typeof foo === null
- using typeof for a null value will return “object”
- If you want to check whether a value is null type use
=== (e.g. foo === null)