<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 問題 Problem 你想針對某一個特別的條件對數組中的每一個元素進行檢查。 You want to be able to check that every element in an array meets a particular condition. ## 方法 Solution 使用Array.every (ECMAScript 5): Use Array.every (ECMAScript 5): ~~~ evens = (x for x in [1..10] by 2) evens.every (x)-> x % 2 == 0 # => true ~~~ Mozilla的JavaScript 1.6中加入了Array.every,并在ECMAScript 5 中標準化。如果想支持沒有實現EC5哦瀏覽器,就看看[underscore.js中的`_.all`](http://documentcloud.github.com/underscore/)。 Array.every was addded to Mozilla’s Javascript 1.6 and made standard with EcmaScript 5\. If you to support browsers that do not implement EC5 then check out?[`_.all`?from underscore.js](http://documentcloud.github.com/underscore/). 舉個真實世界中的例子,假設一個多選的下拉列表,像下面這樣: For a real world example, prentend you have a multiple select list that looks like: ~~~ <select multiple id="my-select-list"> <option>1</option> <option>2</option> <option>Red Car</option> <option>Blue Car</option> </select> ~~~ 現在你想確定用戶只選中的數組,讓我們用Array.every看看: Now you want to verify that the user selected only numbers. Let’s use Array.every: ~~~ validateNumeric = (item)-> parseFloat(item) == parseInt(item) && !isNaN(item) values = $("#my-select-list").val() values.every validateNumeric ~~~ ## 討論 Discussion 這個方法與Ruby中數組的all?方法類似。 This is similar to using ruby’s Array#all? method.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看