Predict 类型 Coercion
预测输出 中等
题目
什么做 这个 code print?
代码
console.log(0 == false);
console.log(0 === false);
console.log("" == 0);
console.log(null == undefined);
提示
== coerces 类型; === 做不.
解释
0 == 假 是真 (假 coerces 到 0). 0 === 假 是假 (不同类型: 数字对比布尔值). "" == 0 is true (empty string coerces to 0). 空 == undefined 是真 (特殊规则: 空 and undefined 是 loosely equal 到每个 other 仅).
相关资源
相关课程
- JavaScript 数据类型
学习关于类型 coercion 规则.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。