let arr = [A, B, C, [D, E, F, [G, H, I]]];
我尝试了很多数组方法,但最终没有得到预期的结果。
我需要这样的输出
let arr = [A, B, C, D, E, F, G, H, I];
最佳答案
你可以这样做,
const arrays = ["A", "B", "C", ["D", "E", "F", ["G","H", "I"]]];
const merge3 = arrays.flat(2); //The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
console.log(merge3);
关于javascript - 有没有办法在javascript中将子数组和子子数组合并为一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59729271/