js对象遍历和拷贝
let obj={name:'user1',age:12,gender:'man'}
for(let attr in obj){
console.log(attr,obj[attr])
}
const keys=Object.keys(obj)
const values=Object.values(obj)
console.log(Object.keys(obj))
console.log(Object.values(obj))
let obj={name:'user1',age:12,gender:'man'}
let obj1={}
let obj2=Object.assign({},obj)
obj2.name='aaa'
console.log(obj2,obj) //{name: 'aaa', age: 12, gender: 'man'} {name: 'user1', age: 12, gender: 'man'}