对象的解构赋值
//复杂的对象的解构赋值
const player = {
nickname:'梦幻西游',
master:'东海龙王',
skill:[{
skillName:'龙吟',
mp:'100',
time:6000
},{
skillName:'龙卷',
mp:'400',
time:3000
},{
skillName:'龙腾',
mp:'900',
time:60000
}]
};
const {nickname} = player; //梦幻西游
const {master} = player; //东海龙王
//const {skill} = player; //得到数组龙吟龙腾龙卷
//const[skill1] = skill; //得到数组第一项龙吟
//const{skill:[ skill1 ]} = player; //得到龙吟数组
//const { skill : [ skill1 , { skillName } ] } = player; //得到skillName的属性值龙卷
const{skill:[skill1,{skillName},{skillName:sklName}]} = player; //sklName得到属性值龙腾