【发布时间】:2020-10-17 16:52:24
【问题描述】:
我正在阅读 You Don't Know JS 一书的“类型和语法”部分,我很难理解这一点。
为什么空数组等于false?
console.log(false == []); // true
【问题讨论】:
-
这能回答你的问题吗? Empty arrays seem to equal true and false at the same time — Google 中“js empty array equals false”的第二个结果(另一个链接是第一个结果)。
-
@pramodsingh 什么?这与这个问题无关。
-
但它为我返回
true!