I currently have a single object
item = { selectedItems: [] };
Here is what I did:
item1 = { ...item };
item2 = Object.assign({}, item);
item3 = Object.create(item);
However, when I make changes to selectedItems
in item1
, those changes apply to all items. This is an Angular project.
What am I doing wrong? Is there a better approach?
Or could it be the browser cache causing this issue? I'm quite puzzled.