ECMAScript 相等性:Type Object 是否为 null?

ECMAScript equality: Is null of Type Object?

我正在尝试实现 ES262, The Abstract Equality Comparison Algorithm 中描述的算法。它指出:

  1. If Type(x) is the same as Type(y), then

    a. If Type(x) is Undefined, return true.

    b. If Type(x) is Null, return true.

所以当我们进行比较时:

console.log(null == {})

它的计算结果应该为真,因为 null 和 {} 具有相同的类型。我理解正确吗?

it should evaluate to true because null and {} have the same type and x is null,

这是你的错误。

类型不同