function removeAllIf(arr, f, opt_obj) {
  let removedCount = 0;
  forEachRight(arr, function(val, index) {
    if (f.call(/** @type {?} */ (opt_obj), val, index, arr)) {
      if (removeAt(arr, index)) {
        removedCount++;
      }
    }
  });
  return removedCount;
}
Removes all values that satisfy the given condition.
@param {IArrayLike<T>} arr Array or array
    like object over which to iterate.
@param {?function(this:S, T, number, ?) : boolean} f The function to call
    for every element. This function
    takes 3 arguments (the element, the index and the array) and should
    return a boolean.
@param {S=} opt_obj An optional "this" context for the function.
@return {number} The number of items removed
@template T,S