title: Fastest way to reset a multidimensional array?
body: <p>Say I have a two dimensional array: <code>vectors[x][y]</code>, and the initial array structure looks like this:</p>
  
  <pre><code>vectors = [    
   [0, 0, 0, 0, 0,],
   [0, 0, 0, 0, 0,],
   [0, 0, 0, 0, 0,],
   [0, 0, 0, 0, 0,],
   [0, 0, 0, 0, 0,]
  ]
  </code></pre>
  
  <p>After some calculations, the data in the array is randomized. What is the fastest way and most efficient way to return the array to it's initial state?</p>
  
  <p>I know that I could just hardcode the above zeroed array and set vectors equal to it again, but I also know that an algorithm such as:</p>
  
  <pre><code>for (var x = 0; x &lt; vectors.length; x++) {
      for (var y = 0; y &lt; vectors[x].length; y++) {
          vectors[x][y] = 0;
      }
  
  }
  </code></pre>
  
  <p>is O(x * y).</p>
  
  <p>So which is the better way? And is there a better, even faster/more efficient way to solve this?</p>
  
  <p>And for the general case of zeroing a multi-dimensional array of any length, which is the best way? (I'm working in JavaScript if it matters)</p>