Original unchanged, return a new one with same key merged, like spread operator...bash
固然上面的作法能夠經過spread operator...徹底來實現:spa
const original ={x:123, y:456}
const newx={...original, ...{y:789,z:'abc'}};
console.log(newx)
{
x: 123,
y: 789,
z: "abc"
}
複製代碼
注意:3d
理解了上面的關鍵詞因而,下面的好理解了:rest
重點看這個例子 stackoverflow.com/questions/5… 關於immutablecode