//组装对象或者数组
const color =["red","blue"];
const colorful=[...color,'green','pink']
console.log(colorful)
const alp= {first:"a",second:"b"}
const alphabets={...alp,third:'c'}
console.log(alphabets);
//获取数组或者对象除了前几项或者除了某几项的其他项
const number=[1,2,3,4,5]
const [first,...rest]=number;
console.log(rest);
const user ={
username:'abc',
gender:'fee',
age:11,
address:"asdasda"
}
const {age,...rest1}=user
console.log(rest1)
//Object ,还可以用于组合成新的 Object 。如果有重复的属性名,右边覆盖左边。
const arr1={
a:1,
b:2,
c:3,
}
const arr2={
c:4,
d:5,
}
const total={...arr1,...arr2}
console.log(total)