javascript
Posted 微笑
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript相关的知识,希望对你有一定的参考价值。
var [a=1,b=2,c=4] = [11,34,55];
console.log(a,b,c);//11 ,34,55
let [x,,y]=[12,23,45];
console.log(x,y);//12,45
let [d,...t]= [12,13,14,15,16];
console.log(`d:${d} t:${t}`);//d:12 t:13,14,15,16
let [u,i,...r] = ["q"];
console.log(u,i,r);//q undefined []
解构赋值允许指定默认值。
let [foo = ‘hello‘]=[];
console.log(foo);//hello
let [bar = ‘how‘,too= ‘world‘] =[‘teach‘];
console.log(bar,too); //teach world
let [sh = 2] = [undefined];
console.log(sh);//2
let [de = 1] = [null];
console.log(de);//null
以上是关于javascript的主要内容,如果未能解决你的问题,请参考以下文章