title: Create copy of multi-dimensional array, not reference - JavaScript
body: <p>This is also referred to as &quot;deep copying&quot;, which I've found some articles on. Closest seems to be <a href="https://stackoverflow.com/questions/565430/deep-copying-an-array-using-jquery">this one</a> but it's for jQuery - I'm trying to do this without a library.</p>
  <p>I've also seen, in two places, that it's possible to do something like:</p>
  <pre><code>arr2 = JSON.decode(JSON.encode(arr1));
  </code></pre>
  <p>But that's apparently inefficient. It's also possible to loop and copy each value individually, and recurs through all the arrays. That seems tiring and inefficient as well.</p>
  <p>So what's the most efficient, non-library way to copy a JavaScript multi-dimensional array <code>[[a],[b],[c]]</code>? I am completely happy with a &quot;non-IE&quot; method if necessary.</p>
  <p>Thanks!</p>