title: Reset Array back to Original values
body: <p>I'm working on a simple game with Javascript, involving changes to an HTML5 canvas. Have a number (10+) of objects entered in an array:</p>
  
  <pre><code>var boxes = [];
      boxes.push({
          x: 0,
          y:canvas.height - 370,
          width: 400,
          height: 20});
      boxes.push({
          x: 300,
          y:canvas.height - 100,
          width: 150,
          height: 90});
  </code></pre>
  
  <p>The entire array is then run through an update function, which changes the x value depending on the player's position:</p>
  
  <pre><code>for (var i = 0; i &lt; boxes.length; i++) {
                  if (boxes[1].x &gt; -3000 + canvas.width) {
                      boxes[i].x -= robot.speed * modifier;
                      robot.x = canvas.width - 300;
                  }; 
              };
  </code></pre>
  
  <p>When the player dies a reset function is run:</p>
  
  <pre><code>var reset = function () {
              robot.x = 0;
              robot.y = 500;
              ++deaths;
              };
  </code></pre>
  
  <p>I'm looking for a way to reset all the values of the <code>boxes</code> array to the original values when this function runs, essentially resetting the map, without having to enter each one manually, ie <code>boxes[1].x = 300</code></p>
  
  <p><a href="https://jsfiddle.net/to31b612/" rel="nofollow">https://jsfiddle.net/to31b612/</a></p>