-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[js] 第92天 解释下为什么{} + [] === 0为true? #904
Comments
那个 {} + [] === 0
+[] === 0
0 === 0
true |
先运算,后比较 |
因为 +[] 为0, |
{} + [] === 0
为true?
加法运算符会触发三种类型转换:
所以,这应该涉及到了隐式转换 一开始以为{}不是代码块,但是这么多人说是代码块,为什么,求解 |
{} 认定是语法块 |
{ }被解释为代码块,不参与计算 所以 +[ ] === 0; |
|
let a = {} + [] |
{} + [] === 0 |
|
第92天 解释下为什么
{} + [] === 0
为true?The text was updated successfully, but these errors were encountered: