es6语法笔记

2018-12-05  本文已影响0人  echo三文鱼

1、拓展运算符...
let arr=[1,2,3]
let arr2=[5,6,7]
console.log([...arr,'4',...arr2]) //[1,2,3,4,5,6,7]

let obj1={left:100,right:200};
let obj2={top:300,bottom:400};
let obj3={...obj1,obj2}
console.log(obj3) //{left:100,right:200,top:300,bottom:400}

2、解构赋值
let {foo:[a,b]}={foo:[10,20],bar:'bbb'}
console.log(a,b)//10,20

上一篇下一篇

猜你喜欢

热点阅读