Created
October 21, 2017 15:31
-
-
Save nekonenene/90d66e4996792b36de3c5ce7f29d1ae5 to your computer and use it in GitHub Desktop.
JavaScriptでのnullっぽい値の処理
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
var zero = 0; | |
var nullString = ""; | |
var nullValue = null; | |
var undefinedValue = undefined; | |
var nanValue = NaN; | |
console.log("## xxx.toString"); | |
console.log(zero + ", " + nullString + ", " + nullValue + ", " + undefinedValue + ", " + nanValue); | |
console.log("## ! xxx"); | |
console.log(!zero + ", " + !nullString + ", " + !nullValue + ", " + !undefinedValue + ", " + !nanValue); | |
console.log("## !! xxx"); | |
console.log(!!zero + ", " + !!nullString + ", " + !!nullValue + ", " + !!undefinedValue + ", " + !!nanValue); | |
console.log("## NaN について"); | |
console.log(typeof nanValue); | |
console.log(-50 < nanValue); | |
console.log("## xxx == null による比較"); | |
console.log(zero == null); | |
console.log(nullString == null); | |
console.log(nullValue == null); | |
console.log(undefinedValue == null); | |
console.log(nanValue == null); |
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
## xxx.toString | |
0, , null, undefined, NaN | |
## ! xxx | |
true, true, true, true, true | |
## !! xxx | |
false, false, false, false, false | |
## NaN について | |
number | |
false | |
## xxx == null による比較 | |
false | |
false | |
true | |
true | |
false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment