码迷,mamicode.com
首页 > 编程语言 > 详细

javascript

时间:2017-09-07 19:24:57      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:code   java   asc   bsp   define   too   允许   指定   efi   

  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

标签:code   java   asc   bsp   define   too   允许   指定   efi   

原文地址:http://www.cnblogs.com/SunShineM/p/7491081.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!