code: function baseFlatten(input, shallow, strict, output) {
    output = output || [];
    var idx = output.length;
    for (var i = 0, length = getLength(input); i < length; i++) {
      var value = input[i];
      if (isArrayLike(value) && (isArray(value) || isArguments(value))) {
        // flatten current level of array or arguments object
        if (shallow) {
          var j = 0,
            len = value.length;
          while (j < len) {
            output[idx++] = value[j++];
          }
        } else {
          baseFlatten(value, shallow, strict, output);
          idx = output.length;
        }
      } else if (!strict) {
        output[idx++] = value;
      }
    }
  
    return output;
  }
docs: Internal implementation of a recursive `flatten` function.