简单JS 数组扁平化
let arr2 = [{ name: '张三', age: '57' },{ name: '李四', age: 24 },[{ name: '沈大', age: 42 },[{ name: '王五', age: 74 },{ name: '赵六', age: 82 }]]] function flatten(arr) { return arr.reduce((result,item)=>{ return result.concat(Array.isArray(item) ? flatten(item) : item); },[]); } console.log('reduce方法:', flatten(arr2))