Make array hold 10 latest entries
<p>I am trying to get a array to hold the 10 latest values, so far it cant get it to work.</p>

<pre><code>var messages = new Array(10);

function addmessage(message) {
    messages.unshift(message);
    messages.length = 10;
}
</code></pre>

<p>But when i try to show the array i cant get it to show the messages in order...</p>

<p>And i display the array with</p>

<pre><code>$.each(messages, function(key, value) {
    if(value != null) {
        $("#messages").append(value + "&lt;br&gt;");
    }
});
</code></pre>
