/**
eg:input: [[5, 7, 4], 3, [89, [8, 9]]]
ouput: [5, 7, 4, 3, 89, 8, 9]
**/
// 不可以使用 Array.prototype.flat() 来实现
const arr = [[5, 7, 4], 3, [89, [8, 9]]]
function kk (arr) {
const newArr = []
arr.forEach((item)=>{
// console.log(Object.prototype.toString.call(item))
if(Object.prototype.toString.call(item) === "[object Number]"){
newArr.push(item)
}else{
newArr.push(...kk(item))
}
})
return newArr
}
console.log(kk(arr))