//解构赋值:了解1,不了解2
//数组的结构赋值
let [a,b] = [10,20]
console.log(a)//10
console.log(b)//20
let c = 10
let d = 20
[c,d] = [d,c]
console.log(c)//20
console.log(d)//10
//对象的结构赋值
let {name,age} = {
name:"小明",
age:2,
friend:"小红"
}
console.log(name)//小明
console.age(age)//2
function createStudent(){
let name = "小明"
let age= 2
let friend = "小红"
return {
name:name,
age:age,
friend:friend
...
...
}
}
const {name} = createStuent()
console.log(name)//小明