0

I have a weird issue, where when I for example do this const data = [...businessCategories]; and make changes to the data variable like this data[itemIndex].selected = true;. What happens is the businessCategories variable get changed as well as data. I don't understand why this happpend since I copying values only not reference.

warCommander
  • 198
  • 1
  • 9
  • You are making a **shallow** copy. `data` is a new array, but the values it holds in it are still references to the same objects referenced by `businessCategories`. – Quentin Jan 25 '22 at 13:59

0 Answers0