From MDN
Object.assign()
copies property values. If the source value is a reference to an object, it only copies that reference value.
And as products[0]
is an object in your data that's why you are facing this shallow copy issue
Instead you can use
let p = JSON.parse(JSON.stringify(products[0]));
…
Top comments (0)