let p = {
name:"zf",
age:23,
sex :"female",
job:{
title:"i am a teacher"
}
}
let ppname,ppage
let {name:pname,age:page} = p
let {name,age,sex,job="worker"} = p
console.log(pname,page)
console.log(name,age,sex)
console.log(name,sex,job);
({name:ppname}= p)
console.log(ppname)
//嵌套解构
let personcopy = {};
(
{
name:personcopy.name,
age:personcopy.age,
job:personcopy.job
}
= p
)
console.log(p)
p.job.title ="i am a student"
console.log(personcopy)
console.log(p)
//
let {job:{title}} =p
console.log(title)
//
console