You'll need to be careful with the order you use the spread operator. If the first object contained c it would not have been replaced. Change the order and you'll get your expected result. Also the spread operator is a shallow copy.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.