Last active
March 2, 2016 03:06
-
-
Save black-black-cat/a1fc7f7270a6559f54c7 to your computer and use it in GitHub Desktop.
运算中的隐式转换
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 a; | |
var b = a * 0; // -> NaN | |
// NaN == NaN -> false | |
// NaN === NaN -> false | |
// b == b -> false | |
if (b == b) { | |
console.log(b * 2 + "2" - 0 + 4); | |
} else { | |
// 通过 - 号将字符串拼接转换为算术运算 | |
console.log(!b * 2 + "2" - 0 + 4); // -> 26 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment