Data-structure to store "last 10" data sets?
<p>I'm currently working with an object Literal to store temporary information to send to clients, it's like a history container for the last 10 sets of data.</p>

<p>So the issue that I', having is figuring out the most efficient way to splice on object as well as push an object in at the start, so basically i have an object, this object has 0 data inside of it.</p>

<p>I then insert values, but what I need to do is when the object reaches 10 keys, I need to pop the last element of the end of object literal, push all keys up and then insert one value at the start.</p>

<p>Take this example object</p>

<pre><code>var initializeData = {
    a : {},
    b : {},
    c : {},
    d : {},
    e : {},
    f : {},
    g : {},
    h : {},
    i : {},
    j : {}
}
</code></pre>

<p>When I insert an element I need <strong>j</strong> to be removed, <strong>i</strong> to become the last element, and <strong>a</strong> to become <strong>b</strong>.</p>

<p>So that the new element becomes <strong>a</strong>.</p>

<p>Can anyone help me solve this issue, I am using node.js but native JavaScript is fine obviously.</p>

<hr>

<p>Working with arrays after advice from replies, this is basically what I am thinking your telling me would be the best solution:</p>

<pre><code>function HangoutStack(n)
{
    this._array = new Array(n);
    this.max    = n;
}

HangoutStack.prototype.push = function(hangout)
{
    if(this._array.unshift(hangout) &gt; this.max)
    {
        this._array.pop();
    }
}

HangoutStack.prototype.getAllItems = function()
{
    return this._array;
}
</code></pre>
