Defining a 3D array in JavaScript
<p>I tried to define a 3D array on Google Sheet, but even though I'm using the <code>.slice()</code> method it keeps passing the array by reference.</p>

<pre><code> var temp = [];
 for (var a = 0; a&lt;archetypesAll.length; a++) {temp[a] = [0, a].slice();};
 var archRank = []; 
 for (var a = 0; a&lt;21; a++) {archRank[a]= temp.slice();};
 archRank[2][1][0] = 'Test';
</code></pre>

<p>I want to edit a single element of the matrix but instead the code above just fills every row with the exact same value ('Test'):</p>

<pre><code>3DMatrix[x][1][0] = 'Test'
</code></pre>