const odd = [1, 3, 5]; const nums = [2 ,4 , 6].concat(odd); const arr = [1, 2, 3, 4]; const arr2 = arr.slice( ) //簡寫后 const odd = [1, 3, 5 ]; const nums = [2 ,4 , 6, ...odd]; console.log(nums); // [ 2, 4, 6, 1, 3, 5 ] const arr = [1, 2, 3, 4]; const arr2 = [...arr]; //和 concat( ) 功能不同的是,用戶可以使用擴展運算符在任何一個數組中插入另一個數組。 const odd = [1, 3, 5 ]; const nums = [2, ...odd, 4 , 6]; //也可以將展開運算符和 ES6 解構符號結合使用 const { a, b, ...z } = { a: 1, b: 2, c: 3, d: 4 }; console.log(a) // 1 console.log(b) // 2 console.log(z) // { c: 3, d: 4 }