function findIndex(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 = 0; i < l; i++) {
    if (i in arr2 && f.call(/** @type {?} */ (opt_obj), arr2[i], i, arr)) {
      return i;
    }
  }
  return -1;
}
Search an array for the first element that satisfies a given condition and
return its index.
@param {IArrayLike<T>|string} 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 index of the first array element that passes the test,
    or -1 if no element is found.
@template T,S