function flatten(...arrays) {
  if (arrays) {
    const result = [];
    flattenInternal(result, arrays);
    return result;
  }

  return undefined;
}
Flattens a nested array (the nesting can be to any depth).

@param {...array} arrays - at least one array must be provided