title: Save a changing variable in javascript
body: <p>In my code I want to save an object that changes during the execution in an array inorder to use it after the execution of the function,so I tried to create a copy of it using this approach:</p>
  <p><code>let copy=[...original]//original is the variable that changes during the execution  </code>
  when I used this approach I noticed that the content of the copied array is the same as the last value of the original array.
  Now I need a method that can keep all the states of the original array in one variable.</p>