My suggestion is that you make a deep copy of your JavaScript object.
This is usually referred to as cloning an object.
See What is the most efficient way to deep clone an object in JavaScript? on various methods how to achieve this.
solved Javascript pass by reference