I'm using an angular service to get a list of inventory items, check to see if an item is in that list, and remove it. However, I don't want to change the service variable itself, just the temporary value I create. Here is my code:
var inventoryItems = InventoryService.all();
console.log("inventorya: ", InventoryService.all());
inventoryItems.splice($index, 1);
console.log("inventoryb: ", InventoryService.all());
I expect InventoryService.all() to return the same value at all times, but it mutates the value returned. I've tried:
var inventoryItems = new Object(InventoryService.all());
but that doesn't appear to work either. What am I doing wrong?