Created
September 19, 2019 21:19
-
-
Save djD-REK/4484e3cad8c59e47fb989eb86d896c43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mightBeNaN = NaN // NaN means "Not-a-Number" | |
// Anything compares false when compared to NaN: | |
console.log(37 === NaN) // false | |
console.log(mightBeNaN === NaN) // false | |
// NaN is the only value that does not equal itself: | |
console.log(mightBeNaN !== mightBeNaN) // true | |
// Creating an invalid Date results in the value NaN: | |
console.log(new Date(`invalid`) !== new Date(`invalid`)) // true | |
// For improved code readability, some developers prefer Number.isNan(): | |
console.log(Number.isNan(mightBeNaN)) // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment