function arrayFilter(array, predicate) {
  var index = 0;
  var iterable = array;

  if (!Array.isArray(array)) {
    iterable = Array.from(array);
  }

  var length = iterable.length;
  var result = [];
  var resIndex = -1;

  while (index < length) {
    var value = iterable[index];

    if (predicate(value, index, iterable)) {
      resIndex += 1;
      result[resIndex] = value;
    }

    index += 1;
  }

  return result;
}
A specialized version of `.filter` for arrays without support for callback
shorthands and `this` binding.

{@link https://github.com/lodash/lodash/blob/master/lodash.js}

@param {Array} array The array to iterate over.
@param {Function} predicate The function invoked per iteration.
@returns {Array} Returns the new filtered array.