-2

三等分测量值和类型。但我想知道它首先比较值并返回 false 的顺序,反之亦然。

4

1 回答 1

1

它首先检查类型:

https://262.ecma-international.org/5.1/#sec-11.9.6

If Type(x) is different from Type(y), return false.
If Type(x) is Undefined, return true.
If Type(x) is Null, return true.
If Type(x) is Number, then
    If x is NaN, return false.
    If y is NaN, return false.
    If x is the same Number value as y, return true.
    If x is +0 and y is −0, return true.
    If x is −0 and y is +0, return true.
    Return false.
If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions); otherwise, return false.
If Type(x) is Boolean, return true if x and y are both true or both false; otherwise, return false.
Return true if x and y refer to the same object. Otherwise, return false.
于 2021-09-10T17:34:13.167 回答