/* ES2015 Rest/Spread */
let [x, ...xs] = [1,2,3]; //Rest
// x=1; xs=[2,3]
let arr = [1, ...xs];// Spread
// arr=[1,2,3]
// 任何实现了Iterable接口的JS对象都是Iterable
// Array/String/Map/Set 是语言内置的Iterable
而能够对Object做Rest/Spead则是一直到ES9也就是ES2018才有的特性
/* ES2018 Objetc Rest/Spread */
let {x, ...kvs} = {x:1, y:2, z:3} // Rest
// kvs = {y:2, z:3}
let o = {x:1, ...kvs} // Spread
// o = {x:1, y:2, z:3}
ES2020新特性
optional chaining
nullish coalescing