<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        Prototype學習工具函數學習($A方法)_prototype

        來源:懂視網 責編:小采 時間:2020-11-27 20:43:27
        文檔

        Prototype學習工具函數學習($A方法)_prototype

        Prototype學習工具函數學習($A方法)_prototype:$A方法: Accepts an array-like collection (anything with numeric indices) and returns its equivalent as an actual Array object. This method is a convenience alias of Array.from, but
        推薦度:
        導讀Prototype學習工具函數學習($A方法)_prototype:$A方法: Accepts an array-like collection (anything with numeric indices) and returns its equivalent as an actual Array object. This method is a convenience alias of Array.from, but

        $A方法:
        Accepts an array-like collection (anything with numeric indices) and returns its equivalent as an actual Array object. This method is a convenience alias of Array.from, but is the preferred way of casting to an Array.
        代碼如下:
        function $A(iterable) {
        if (!iterable) return [];
        if ('toArray' in Object(iterable)) return iterable.toArray();
        var length = iterable.length || 0, results = new Array(length);
        while (length--) results[length] = iterable[length];
        return results;
        }

        如果傳進來的參數為null, undefined and false 則直接返回空數組
        如果傳進來的參數對象里有toArray方法,這直接調用參數的toArray方法,因為有許多Prototype對象里面已經定義好了toArray方法,所以可以直接調用toArray方法
        例如:
        代碼如下:
        var array={
        toArray : function(){
        return [1,2,3];
        }
        }
        //1,2,3
        alert($A(array));

        接下來根據參數的length建立新數組,然后逐個把參數中的元素復制到新數組中去,最后返回新數組對象
        下面給出prototype幫助文檔的一段說明和例子也許更能說明這個函數的作用:
        代碼如下:
        /*The well-known DOM method document.getElementsByTagName() doesn't return an Array, but a NodeList object that implements the basic array "interface." Internet Explorer does not allow us to extend Enumerable onto NodeList.prototype, so instead we cast the returned NodeList to an Array:*/
        var paras = $A(document.getElementsByTagName('p'));
        paras.each(Element.hide);
        $(paras.last()).show();

        還有一點:
        Array.from = $A;
        數組對象的from靜態方法和$A是一個方法

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        Prototype學習工具函數學習($A方法)_prototype

        Prototype學習工具函數學習($A方法)_prototype:$A方法: Accepts an array-like collection (anything with numeric indices) and returns its equivalent as an actual Array object. This method is a convenience alias of Array.from, but
        推薦度:
        標簽: pro 函數 方法)
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 日韩人妻一区二区三区免费 | 99久久免费国产特黄| 成人a免费α片在线视频网站| 亚洲天堂一区在线| 日本人的色道免费网站| 亚洲成在人线中文字幕| 美女内射毛片在线看免费人动物| 亚洲色图.com| 好男人www免费高清视频在线| 精品亚洲AV无码一区二区| 天天看免费高清影视| 日本亚洲中午字幕乱码| 免费一级毛片在线观看| a一级毛片免费高清在线| 久久久久久久综合日本亚洲| 100部毛片免费全部播放完整| 亚洲一级片在线观看| 日本最新免费不卡二区在线| 免费无码又爽又黄又刺激网站| 亚洲毛片av日韩av无码| 国产免费无码一区二区| 亚洲人成人77777在线播放| 永久免费视频v片www| 一个人看的www在线免费视频| 亚洲av永久无码精品秋霞电影影院| 最近2019中文字幕免费直播| 亚洲五月综合缴情婷婷| 亚洲AV成人精品日韩一区18p| 今天免费中文字幕视频| 亚洲 日韩 色 图网站| 亚洲а∨天堂久久精品| 一级毛片免费视频| 国产精品亚洲精品日韩电影| 亚洲免费观看视频| 夭天干天天做天天免费看| 成全视成人免费观看在线看| 亚洲www在线观看| 久久亚洲国产成人影院网站 | 亚洲神级电影国语版| 免费A级毛片无码久久版| 午夜老司机永久免费看片|