国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

The Abstract Equality Comparison Algorithm

Karuru / 2558人閱讀

11.9.3 The Abstract Equality Comparison Algorithm

The comparison x == y, where x and y are values, produces true or false. Such a comparison is performed as follows:

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

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.

If x is null and y is undefined, return true.

If x is undefined and y is null, return true.

If Type(x) is Number and Type(y) is String, return the result of the comparison x == ToNumber(y).

If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y.

If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.

If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).

If Type(x) is either String or Number and Type(y) is Object, return the result of the comparison x == ToPrimitive(y).

If Type(x) is Object and Type(y) is either String or Number, return the result of the comparison ToPrimitive(x) == y.

Return false.

NOTE 1
Given the above definition of equality:

String comparison can be forced by: "" + a == "" + b.

Numeric comparison can be forced by: +a == +b.

Boolean comparison can be forced by: !a == !b.

NOTE 2
The equality operators maintain the following invariants:

A != B is equivalent to !(A == B).

A == B is equivalent to B == A, except in the order of evaluation of A and B.

NOTE 3
The equality operator is not always transitive. For example, there might be two distinct String objects, each representing the same String value; each String object would be considered equal to the String value by the == operator, but the two String objects would not be equal to each other. For Example:

new String("a") == "a" and "a" == new String("a") are both true.

new String("a") == new String("a") is false.

NOTE 4
Comparison of Strings uses a simple equality test on sequences of code unit values. There is no attempt to use the more complex, semantically oriented definitions of character or string equality and collating order defined in the Unicode specification. Therefore Strings values that are canonically equal according to the Unicode standard could test as unequal. In effect this algorithm assumes that both Strings are already in normalised form.

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/85436.html

相關文章

  • 你真的理解==和===的區別嗎?

    摘要:上面的理解是錯的,和返回就可以推翻。解釋不清楚和是相等的。和的規則類似,唯一少了轉換的一步。三高級階段參考規范真正理解真的如高設所說的那樣嗎其實不然。來分析一個經典的例子,看完徹底理解的強制轉換。 showImg(https://segmentfault.com/img/remote/1460000011658462?w=512&h=321); 用中文怎么叫合適?相等?全等?其實并不合...

    TwIStOy 評論0 收藏0
  • Advanced JS Notebook

    How JavaScript works? JavaScript is a single-threaded language that can be non-blocking. showImg(https://segmentfault.com/img/bVbiqTf?w=1678&h=852); JavaScript Engine For the code below: const f()=>{ ...

    jimhs 評論0 收藏0
  • 前端面試中遇到 [] == ![] ? 刨祖墳式博客解析,從 ECMAScript 規范說起,比脫下

    摘要:這種情況,它們返回一個布爾型值。語法描述邏輯非如果能轉換為,返回如果能轉換為,則返回。轉中能夠轉換為的字面量是可枚舉的,包含空字符串。 博客 github 地址: https://github.com/HCThink/h-blog/blob/master/interesting/in5.md github 首頁(star+watch,一手動態直達): https://github....

    codeGoogle 評論0 收藏0
  • 重讀Javascript之Object

    摘要:對象是中最常的內置對象之一。為了節省內存,使用一個共享的構造器使用更安全的引用如果不是或,拋出一個異常。使創建的一個新的對象為,就和通過表達式創建一個新對象一樣,是標準內置的構造器名設置的內部屬性為。方法返回一個該對象的字符串表示。 Object 對象是Javascript中最常的內置對象之一。除了null 和 undefined,其他的所有的都可以轉換為對象。可以把對象看成含有鍵值一...

    Alex 評論0 收藏0
  • 怪異的JavaScript系列(一)

    摘要:是一門偉大的語言,它擁有非常簡潔的語法,龐大的生態系統,以及最重要的有一個偉大的社區支撐著。可是因為它已經被廣泛使用,所以委員會覺得保留它,但是違背了的規范。其實最小的數是,盡管它不是一個實際存在的數。 譯者按: JavaScript有很多坑,經常一不小心就要寫bug。 原文: What the f*ck JavaScript? 譯者: Fundebug 為了保證可讀性,本文采...

    darry 評論0 收藏0

發表評論

0條評論

Karuru

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<