code: function filter(array, f) {
          if (array) {
              var len = array.length;
              var i = 0;
              while (i < len && f(array[i]))
                  i++;
              if (i < len) {
                  var result = array.slice(0, i);
                  i++;
                  while (i < len) {
                      var item = array[i];
                      if (f(item)) {
                          result.push(item);
                      }
                      i++;
                  }
                  return result;
              }
          }
          return array;
      }
docs: Filters an array by a predicate function. Returns the same array instance if the predicate is
  true for all elements, otherwise returns a new array instance containing the filtered subset.