How do I set the value of another variable to that of an array?
<p>I'm unsure what the problem is here, but here is my code</p>

<pre><code>var btotal = [];
var songarray = [];
function whileplaying() {
    var playingSound = soundManager.getSoundById('aSound');
    for (var i=0;i&lt;8;i++) {
        var ttotal = 0;
        for (var n=0;n&lt;32;n++) {
            var eblock = (i*32)+n;
            ttotal = ttotal+(playingSound.eqData.left[eblock]*100);
        }
        ttotal = ttotal/32;
        btotal[i] = ttotal;
    }
    console.log(btotal);
    songarray.push(btotal);
}
</code></pre>

<p>To explain, while the sound is playing I get an array with a length of 8, summing up the EQ values of that frequency block. At the end I append this array to songarray, so the theory is that songarray is an array containing the sound's EQ data in arrays.</p>

<p>The problem is that when I then get the value of songarray, it has however many arrays in it that I expected, but they are all identical, and are all what the last data point was, the latest value of btotal.</p>

<p>So this code would run, and console would display (for example):</p>

<pre><code>[42.743750000000006, 2.98125, 0.10625000000000001, 0, 0, 0, 0, 0]
[38.859374999999986, 2.8, 0.09375, 0, 0, 0, 0, 0]
[56.26874999999998, 21.831250000000004, 3.853125, 0.340625, 0, 0, 0, 0]
[46.459374999999994, 19.584374999999998, 1.4, 0, 0, 0, 0, 0]
[38.08125, 11.8, 1.0750000000000002, 0, 0, 0, 0, 0] 
</code></pre>

<p>However the contents of song array goes like:</p>

<pre><code>0: Array[8]
0: 38.08125
1: 11.8
2: 1.0750000000000002
3: 0
4: 0
5: 0
6: 0
7: 0
length: 8
__proto__: Array[0]
1: Array[8]
0: 38.08125
1: 11.8
2: 1.0750000000000002
3: 0
4: 0
5: 0
6: 0
7: 0
length: 8
__proto__: Array[0]
</code></pre>

<p>Which are all the contents of the latest btotal array. This leads me to believe that each entry in songarray merely points to btotal. So how do I make it so that each array in songarray is the value of btotal at the time I append it, and not merely a pointer?</p>
