<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 問題 Problem 你想基于某個布爾條件來過濾數組。 You want to be able to filter arrays based on a boolean condition. ## 方法 Solution 使用`Array.filter`(ECMAScript 5): Use Array.filter (ECMAScript 5): ~~~ array = [1..10] array.filter (x) -> x > 5 # => [6,7,8,9,10] ~~~ 在pre-EC5的實現中,給Array的原型擴展一個過濾函數,這個函數接受一個回調函數,并迭代整個數組,收集所有調用過濾函數的為true的元素。在復寫這個函數的之前需要先確保這個是否已經實現了: In pre-EC5 implementations, extend the Array prototype to add a filter function which will take a callback and perform a comprension over itself, collecting all elements for which the callback is true. Be sure to check if the function is already implemented before overwriting it: ~~~ # Extending Array's prototype unless Array::filter Array::filter = (callback) -> element for element in this when callback(element) array = [1..10] # Filter odd elements filtered_array = array.filter (x) -> x % 2 == 0 # => [2,4,6,8,10] # Filter elements less than or equal to 5: gt_five = (x) -> x > 5 filtered_array = array.filter gt_five # => [6,7,8,9,10] ~~~ ## 討論 Discussion 這個方法的用法與Ruby中Array的select方法類似。 This is similar to using ruby’s Array#select 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>

                              哎呀哎呀视频在线观看