这个好像是es6的语法
连续解构赋值
举例:
const a = {
b: 6,
c: 7,
d: {
e: 8,
f: {
g: 9
}
}
}
console.log(a)
console.log(a.b)
console.log(a.c)
console.log(a.d)
console.log(a.d.e)
console.log(a.d.f)
console.log(a.d.f.g)
console.log("===========================")
console.log("看上下两种形式结果是否一样")
console.log(a)
const {b} = a
console.log(b)
const {c} = a
console.log(c)
const {d} = a
console.log(d)
const {d:{e}} = a
console.log(e)
const {d:{f}} = a
console.log(f)
const {d:{f:{g}}} = a
console.log(g)
连续解构赋值并给对象重命名
举例:
const A = {
B:{
C:1
}
}
const {B:{C:data}} = A
console.log(data)
|