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

資訊專欄INFORMATION COLUMN

es String 內(nèi)部實現(xiàn)邏輯標準

Jingbin_ / 3172人閱讀

摘要:返回值類型是根據(jù)傳入的值是否為空字符串,選擇性調(diào)用方法代碼是一個抽象的操作,將傳入的參數(shù)值轉(zhuǎn)換為類型的值,這一過程是參照一個規(guī)則進行,規(guī)則如下表傳入?yún)?shù)的類型返回的結(jié)果返回參數(shù)值參考下面詳細闡述調(diào)用方法,返回詳細闡述類型包括特殊的數(shù)值,還包

String(value)

返回值類型是 string value

根據(jù)傳入的值是否為空字符串,選擇性調(diào)用 ToString(value) 方法

代碼

function String(value) {
    return value === "" ? "" : ToString(value)
}
ToString(value)
ToString 是一個抽象的操作,將傳入的參數(shù)值轉(zhuǎn)換為 String 類型的值,這一過程是參照一個規(guī)則進行,規(guī)則如下表
傳入?yún)?shù)的類型 返回的結(jié)果
Undefined "undefined"
Null "null"
Boolean true => "true" false => "false"
String 返回 參數(shù)值
Number 參考下面詳細闡述
Object 1. 調(diào)用 ToPrimitive 方法,var primValue = ToPrimitive(input argument hintString); 2. 返回 ToString(primValue)
詳細闡述 Number 類型

Number 包括 NaN 特殊的數(shù)值,還包括 Infinity 無限大和無限小的數(shù)值,包括能表示能存儲下的正常浮點數(shù)

以下 m 代替?zhèn)魅氲?Number 類型的參數(shù)的值

當 m 為 NaN,返回 String 形的 "NaN"

當 m 為 +0 或者 -0,返回 String 形的 "0"

當 m < 0, 返回 -ToString(-m),意思是首先提取出 - 符號,再對 -m 調(diào)用 ToString 方法

當 m 為 infinity,返回 String 形的 "Infinity"

以下為重點,當 m > 0 且不是 infinity 時的內(nèi)部抽象操作

Otherwise, let n, k, and s be integers such that k ≥ 1, 10k?1 ≤ s < 10k, the Number value for s × 10n?k is m, and k is as small as possible. Note that k is the number of digits in the decimal representation of s, that s is not divisible by 10, and that the least significant digit of s is not necessarily uniquely determined by these criteria.

If k ≤ n ≤ 21, return the String consisting of the k digits of the
decimal representation of s (in order, with no leading zeroes),
followed by n?k occurrences of the character ‘0’.

If 0 < n ≤ 21, return the String consisting of the most significant n
digits of the decimal representation of s, followed by a decimal point
‘.’, followed by the remaining k?n digits of the decimal
representation of s.

If ?6 < n ≤ 0, return the String consisting of the character ‘0’,
followed by a decimal point ‘.’, followed by ?n occurrences of the
character ‘0’, followed by the k digits of the decimal representation
of s.

Otherwise, if k = 1, return the String consisting of the single digit
of s, followed by lowercase character ‘e’, followed by a plus sign ‘+’
or minus sign ‘?’ according to whether n?1 is positive or negative,
followed by the decimal representation of the integer abs(n?1) (with
no leading zeros).

Return the String consisting of the most significant digit of the
decimal representation of s, followed by a decimal point ‘.’, followed
by the remaining k?1 digits of the decimal representation of s,
followed by the lowercase character ‘e’, followed by a plus sign ‘+’
or minus sign ‘?’ according to whether n?1 is positive or negative,
followed by the decimal representation of the integer abs(n?1) (with
no leading zeros).

通俗的理解就是 科學計數(shù)法表示

參考
http://es5.github.io/#x15.5.1.1
http://es5.github.io/#x9.8

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

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

相關(guān)文章

  • ToPrimitive 內(nèi)部邏輯標準

    摘要:是包含兩個參數(shù)的抽象的操作,一個是參數(shù),一個是可選參數(shù),該操作就是將轉(zhuǎn)換為非類型的值,即數(shù)據(jù)類型的種普通類型。在第一個參數(shù)為時,有可能將該轉(zhuǎn)換不止一種基本類型的值。 ToPrimitive 是包含兩個參數(shù)的抽象的操作,一個是 input argument 參數(shù),一個是可選參數(shù) PreferredType,該操作就是將 input argument 轉(zhuǎn)換為 no-Object type ...

    chanthuang 評論0 收藏0
  • Zepto 源碼分析 2 - Polyfill 設(shè)計

    摘要:此模塊包含的設(shè)計思路即為預以匹配降級方案。沒有默認編譯該模塊,以及利用該模塊判斷后提供平臺相關(guān)邏輯的主要原因在于其設(shè)計原則的代碼完成核心的功能。此處,也引出了代碼實現(xiàn)的另一個基本原則面向功能標準,先功能覆蓋再優(yōu)雅降級。 在進入 Zepto Core 模塊代碼之前,本節(jié)簡略列舉 Zepto 及其他開源庫中一些 Polyfill 的設(shè)計思路與實現(xiàn)技巧。 涉及模塊:IE/IOS 3/Dete...

    chuyao 評論0 收藏0
  • JavaScript是如何工作的:深入類和繼承內(nèi)部原理+Babel和 TypeScript 之間轉(zhuǎn)換

    摘要:下面是用實現(xiàn)轉(zhuǎn)成抽象語法樹如下還支持繼承以下是轉(zhuǎn)換結(jié)果最終的結(jié)果還是代碼,其中包含庫中的一些函數(shù)??梢允褂眯碌囊子谑褂玫念惗x,但是它仍然會創(chuàng)建構(gòu)造函數(shù)和分配原型。 這是專門探索 JavaScript 及其所構(gòu)建的組件的系列文章的第 15 篇。 想閱讀更多優(yōu)質(zhì)文章請猛戳GitHub博客,一年百來篇優(yōu)質(zhì)文章等著你! 如果你錯過了前面的章節(jié),可以在這里找到它們: JavaScript 是...

    PrototypeZ 評論0 收藏0
  • ECMAScript 2018 標準導讀

    摘要:標準對象,語義由本規(guī)范定義的對象。三個冒號作為分隔符分割數(shù)字字符串文法的產(chǎn)生式。所有因為帶來的問題,基本上是占著茅坑不拉屎的行為導致。以數(shù)組測試操作為例,標準中的描述如下相對于來說,規(guī)范中增加了對的處理。 前言 本文是對《ECMAScript 2018 Language Specification》的解讀。本文是對標準的概述性導讀,不是對 ES2018特性的詳細描述,也不會針對某個技術(shù)...

    MiracleWong 評論0 收藏0
  • ES6 Symbol - 一些重要的Symbol屬性

    摘要:是一個布爾值,用于確定當調(diào)用數(shù)組的方法時,如果傳入?yún)?shù)是一個數(shù)組,是否需要將這個數(shù)組拍平。與其他的屬性不同的是,并不默認出現(xiàn)在標準對象中。 ECMAScript 6 通過在原型鏈上定義與Symbol相關(guān)的屬性來暴露語言內(nèi)部邏輯,使得開發(fā)者可以對一些語言的默認行為做配置。接下來我們來看看有哪些重要的Symbol屬性可供我們使用: 1: Symbol.hasInstance 一個在執(zhí)行 i...

    Barrior 評論0 收藏0

發(fā)表評論

0條評論

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