function steamrollArray(arr) {
  let result = arguments[1] ? arguments[1] : [];
  for (let i = 0; i < arr.length; i++) {
    if (!Array.isArray(arr[i])) {
      result.push(arr[i]);
    } else {
      steamrollArray(arr[i], result);
    }
  }
  return result;
}

console.log(steamrollArray([1, {}, [3, [[4]]]]));

steamrollArray([[["a"]], [["b"]]]) should return ["a", "b"].

steamrollArray([1, [2], [3, [[4]]]]) should return [1, 2, 3, 4].

steamrollArray([1, [], [3, [[4]]]]) should return [1, 3, 4].

steamrollArray([1, {}, [3, [[4]]]]) should return [1, {}, 3, 4].