CoffeeScripte 中 existential operator 在编译成 javascript 时
//coffee
console.log x?
//js
console.log(typeof x !== "undefined" && x !== null);
为什么不是
console.log(x !== undefined && x !== null);
为什么在判断 undefined 的时候,不直接判断呢? 这样做的好处是什么
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
因为undefined并不是保留字,可以被覆盖,如:
也是可以的。这样一来直接判等就无效了