code: function indexOf(haystack, needle) {
    if (typeof haystack === 'string')
      return haystack.indexOf(needle);
  
    for (let i = 0, j = 0, l = haystack.length, n = needle.length; i < l; i++) {
      if (haystack[i] === needle[j]) {
        j++;
  
        if (j === n)
          return i - j + 1;
      }
      else {
        j = 0;
      }
    }
  
    return -1;
  }
docs: Abstract indexOf helper needed to find the given subsequence's starting
  index in the given sequence. Note that this function may seem naive
  because it misses cases when, for instance, the subsequence is not found
  but this is of no concern because we use the function in cases when it's
  not possible that the subsequence is not found.
  
  @param  {mixed}  haystack - Target sequence.
  @param  {mixed}  needle   - Subsequence to find.
  @return {number}          - The starting index.