1.数组的解构赋值
var a = 1;
var b = 2;
var c = 3;
var a=1,b=2,c=3;
let [a,b,c] = [1,2,3];
如果不定义则为undefind
默认值
let [a=111,b,c] = [,2,3];
2.对象的解构赋值
let {foo,bar} = {foo:'xxx',bar:'cccc'}
let {foo,bar} = {bar:'cccc',foo:'xxx',}
对象属性别名,有别名原名就无效
let {foo:adc,bar} = {bar:'cccc',foo:'xxx',}
let {sin,cos,redom} = Math;
3.字符串的解构赋值
let [a,b,c,d,e] = 'hello';
a=h,b=e,c=l.....
let {length} = 'hello' //length=5