Adding/deleting object properties and removing null
<p>I am trying to remember open accordions in a custom plugin. The first accordion is open by default, so:</p>

<pre><code>var active = [0];
</code></pre>

<p>I click on accordions and then read from <code>localStorage</code> to get the values. Inside my click event:</p>

<pre><code>var active = JSON.parse(localStorage.getItem(outerName)),
    tab = $(this).find('h3').index(ui.tab[0]);

if (tab in active) {
    delete active[tab];
} else {
    active[tab] = tab;
}
for (var i = 0; i &lt; this.length; i++) {
    if (active[i] == null) {
        active.splice(i, 1);
        i--;
    }
}
localStorage.setItem(outerName, JSON.stringify(active));
</code></pre>

<p>This works, except where I remove the first accordion and then click the second and I'll get duplicated values <code>[1,1]</code>. I have already removed the null values each time so this is the cause but I don't know how to get the values properly so that if I toggle an accordion it will get removed from the object.</p>

<p><code>[0,3]</code> = Accordion 1 and 4 is open</p>

<p><code>[0,1]</code> = Accordion 1 and 2 is open</p>
