Created
February 11, 2014 08:07
-
-
Save south37/8930906 to your computer and use it in GitHub Desktop.
NaNの判定について ref: http://qiita.com/south37/items/e400a3a698957ab4aa7a
This file contains 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
isNaN(NaN); // true | |
isNaN("foo"); // true | |
isNaN(undefined); // true | |
isNaN({}); // true | |
isNaN({ valueOf: "foo" }); // true |
This file contains 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
NaN === NaN // falseを返す!!! | |
function isReallyNaN(x) { | |
return x !== x; // xがNaNであればtrue, それ以外ではfalse | |
} |
This file contains 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
Number.isNaN(NaN); // true | |
Number.isNaN('NaN'); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment