let arr = [
{
name: '张三',
hobby: "抽烟,喝酒,烫头"
},
{
name: '李四',
hobby: "打麻将,蹦迪,烫头"
}
]
// 将数组对象的中的 hobby 属性变成数组
const result = arr.map((item) => {
return Object.assign({}, { name: item.name, hobby: item.hobby.split(',') })
})
console.log(result, 'result')
标签:name,对象,item,result,数组,hobby,属性
From: https://www.cnblogs.com/orangeczs/p/17117176.html