function forEachRight(arr, f, opt_obj) {
  const l = arr.length;  // must be fixed during loop... see docs
  const arr2 = (typeof arr === 'string') ? arr.split('') : arr;
  for (let i = l - 1; i >= 0; --i) {
    if (i in arr2) {
      f.call(/** @type {?} */ (opt_obj), arr2[i], i, arr);
    }
  }
}
Calls a function for each element in an array, starting from the last
element rather than the first.

@param {IArrayLike<T>|string} arr Array or array
    like object over which to iterate.
@param {?function(this: S, T, number, ?): ?} f The function to call for every
    element. This function
    takes 3 arguments (the element, the index and the array). The return
    value is ignored.
@param {S=} opt_obj The object to be used as the value of 'this'
    within f.
@template T,S