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
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
本文标题:小技巧
本文链接:https://www.haomeiwen.com/subject/wabxqqtx.html
网友评论