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'} 标签:遍历,obj,name,Object,js,let,console,拷贝,log From: https://www.cnblogs.com/howhy/p/17434206.html