我有一個巨大的多維數組,我想轉換成單維數組,真正的問題是數組是動態的,它可以是一個儘可能地深入,而且我不能提前確定。張貼在這裏的示例如何將深度多維數組轉換爲單維數組 - Javascript
var myArray = [
"hello",
["berries", "grouped", 88, "frozen"],
[
"stuff",
[
"mash",
["melon", "freeze", 12, "together"],
"people"
],
"car"
],
[
"orange",
"code",
84,
["mate", "women", "man"]
],
["bus", "car", 345, "lorry"],
"world"
];
應當轉換爲一維陣列狀
["hello","berries","grouped",88,"frozen","stuff","....."]
的解決方案應該怎麼樣子的呢? – maja
編輯我的問題 –