对象
let obj = {
name: "zjq",
age: "18",
myhabby: {
habby1: '唱歌',
habby2: "跳舞",
habby3: "篮球"
}
}
let {
name, age, myhabby } = obj
console.log(name, age, myhabby);
let {
habby1, habby2, habby3 } = myhabby
console.log(habby1, habby2, habby3);
2.
let obj = {
name: "zjq",
age: "18",
myhabby: {
habby1: '唱歌',
habby2: "跳舞",
habby3: "篮球"
}
}
let {
name, age, myhabby:habby } = obj
let {
habby1, habby2, habby3 } = habby
console.log(habby1, habby2, habby3);
3.
let obj = {
name: "zjq",
age: "18",
myhabby: {
habby1: '唱歌',
habby2: "跳舞",
habby3: "篮球"
}
}
let {
name, age, myhabby: {
habby1, habby2, habby3 } } = obj
console.log(name, age, habby1, habby2, habby3);
数组
let arr =[111,222,333,{
name:'zjq'},[1,2,3]]
let [a,b,c,d]=arr
console.log('a,b,c,d===', a,b,c,d);
2.
let arr =[111,222,333,{
name:'zjq'},[1,2,3]]
let [a,...b]=arr
console.log('b===', b);
console.log('a...b===', a,...b);