Strict 对比 Loose Equality
单选题 中等
题目
什么做 `"5" == 5` evaluate 到 in JavaScript?
提示
== 运算符执行类型 coercion 之前 comparing.
解释
The loose equality operator == performs type coercion. It converts the string "5" to the number 5 before comparing, so "5" == 5 is true. However, "5" === 5 is false because === checks both value and type without coercion. Best practice is to always use ===.
相关资源
相关课程
- 条件 (如果/else)
学习如何如果/else 条件工作.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。