小技巧
程序员文章站
2022-03-20 13:06:38
...
let obj = {a:2,b:3}
let obj1 = {a:5, b:6}
let {a} = obj
let {a:a1} = obj1
console.log(a1) //5
console.log(a) //2
let {a:a1}将你得到的对应变量a改名为变量a1,但是变量a的值并不会改变,所以其实
let {a:a1}=obj1
就相当于把对应的a属性也换成了a1
let a1= obj.a1
上一篇: 画图小总结