1、变量比值多可以设置变量默认值 解构
let [a,b,c,d='aaa']=[12,34,24]
2、变量比值少可以用剩余参数解构
let [a,...b]=[11,22,44,55] //a 11 b [22,44,55]
3、按需赋值
let [a,,b]=[5,6,9]
4、数组嵌套解构
let [a,b,arr]=[1,2,[5,8,9]]
let [a,b,[c,d,e]]=[1,2,[5,8,9]]
5、数组嵌套对象
let person=[{name:'howhy',score:{math:0,english:78,chinese:77}}]
let [{name,score:{math,chinese,english}}]=person
6、对象解构
let obj={name:'use1',age:12}
let {name,age}=obj
let {name:uname,age}=obj
let student={name:'zhangsan',score:{math:90,english:88,chinese:87}}
let {name,score:{math,chinese,english}}=student
标签:name,chinese,js,score,let,解构,数据,math From: https://www.cnblogs.com/howhy/p/17434032.html