let arr = [
{ name: 'zs', age: 18 },
{ name: 'ks', age: 20 },
{ name: 'wy', age: 18 },
]
转换为
let arr = [
[{ name: 'zs', age: 18 }],
[{ name: 'ks', age: 20 }],
[{ name: 'wy', age: 18 }],
]
//实现代码
let newArr = []
arr.forEach((item) => {
newArr.push([item])
})
let arr = [
{ name: 'zs', age: 18 },
{ name: 'ks', age: 20 },
{ name: 'wy', age: 18 },
]处理为
[
[ "zs", 18],
[ "ks", 20],
[ "wy",18]
]
let newArr = []
arr.forEach((item) => {
newArr.push(Object.values(item))
})