亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專欄INFORMATION COLUMN

The Abstract Equality Comparison Algorithm

Karuru / 2603人閱讀

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.

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/85436.html

相關(guān)文章

  • 你真的理解==和===的區(qū)別嗎?

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

    TwIStOy 評(píng)論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 評(píng)論0 收藏0
  • 前端面試中遇到 [] == ![] ? 刨祖墳式博客解析,從 ECMAScript 規(guī)范說(shuō)起,比脫下

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

    codeGoogle 評(píng)論0 收藏0
  • 重讀Javascript之Object

    摘要:對(duì)象是中最常的內(nèi)置對(duì)象之一。為了節(jié)省內(nèi)存,使用一個(gè)共享的構(gòu)造器使用更安全的引用如果不是或,拋出一個(gè)異常。使創(chuàng)建的一個(gè)新的對(duì)象為,就和通過(guò)表達(dá)式創(chuàng)建一個(gè)新對(duì)象一樣,是標(biāo)準(zhǔn)內(nèi)置的構(gòu)造器名設(shè)置的內(nèi)部屬性為。方法返回一個(gè)該對(duì)象的字符串表示。 Object 對(duì)象是Javascript中最常的內(nèi)置對(duì)象之一。除了null 和 undefined,其他的所有的都可以轉(zhuǎn)換為對(duì)象??梢园褜?duì)象看成含有鍵值一...

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

    摘要:是一門偉大的語(yǔ)言,它擁有非常簡(jiǎn)潔的語(yǔ)法,龐大的生態(tài)系統(tǒng),以及最重要的有一個(gè)偉大的社區(qū)支撐著??墒且?yàn)樗呀?jīng)被廣泛使用,所以委員會(huì)覺(jué)得保留它,但是違背了的規(guī)范。其實(shí)最小的數(shù)是,盡管它不是一個(gè)實(shí)際存在的數(shù)。 譯者按: JavaScript有很多坑,經(jīng)常一不小心就要寫bug。 原文: What the f*ck JavaScript? 譯者: Fundebug 為了保證可讀性,本文采...

    darry 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<