jsES6对象复制另一个对象部分的值
let obj1 = {
name:'zhangsan',
age:'14',
sex:'m'
}
let obj2 = {}
// 直接取obj中的字段
this.obj2 = (({ name,age}) => ({ name,age}))(obj1)
console.log(obj2,'obj2');// { name:'zhangsan',age:'14' }
// 将obj1中字段修改名称存入obj2 (id为修改字段名称)
obj2 = (({ name,age}) => ({ name,id:age}))(obj1)
console.log(obj2,'obj2');// { name:'zhangsan',id:'14' }