我见过许多问题/答案主题是通过交替值合并两个数组。他们是这样工作的:
let array1 = ["a", "b", "c", "d"];
let array2 = [1, 2];
let outcome = ["a",1 ,"b", 2, "c", "d"]
但我希望输出更加高效,并且根据数组大小均匀分配值。
expected outcome = ["a","b", 1, "c", "d", 2]
其他场景
let array2 = [1];
expected outcome = ["a","b", 1, "c", "d"]
实现这种合并的最佳方式应该是什么?