Order.prototype.selectItem = function(newItem) { ...
newItem is the object I want to copy and then modify the copy without modifying the original newItem.
var newSelectedItem = newItem;
newSelectedItem.orderIndex = this.selectedItems.length + 1;
Changing the orderIndex of the copy will also change the original newItem.
Question: How do I copy and then modify the copy without modifying the original newItem.
Thanks!
If you’re using jQuery (which I’d suggest), you can clone objects per this post:
What is the most efficient way to deep clone an object in JavaScript?