2nd value in javascript array always unidentified
<p>Got this script:</p>

<pre><code>&lt;script type="text/javascript"&gt;
var imones = [];
imones.push('example.com');
imones.push('cnn.com');
imones.push('apple.com');


var beforeloadingtime = (new Date()).getTime();
var beforeTime = [];
beforeTime[0] = beforeloadingtime;
$.each(imones, function (index, value) {
    var jsonnuorodos = "http://anyorigin.com/get?url=" + imones[index] + "&amp;callback=?";
    $.getJSON(jsonnuorodos, function (data) {
        var iframe = $("#output")[0];
        var doc = iframe.document;
        if (iframe.contentDocument) {
            doc = iframe.contentDocument;
        } else if (iframe.contentWindow) {
            doc = iframe.contentWindow.document;
        }
        doc.open();
        doc.writeln(data.contents);
        doc.close();
        var loadingtime = (new Date()).getTime();
        beforeTime.push(loadingtime);

        var result;
        result = (beforeTime[index + 1] - beforeTime[index]) / 1000;
        console.log("result - " + result);
    });
});
&lt;/script&gt;
</code></pre>

<p>In console i get these results:</p>

<pre><code>result - 1.741 
result - NaN 
result - 0.86 
</code></pre>

<p>I am getting NaN on my 2nd result because beforeTime[index+1] value is always unidentified.</p>

<p>Edit:
if i write <code>console.log("index= "+[index]); console.log("index+1= "+[index+1]);</code> i am getting:</p>

<pre><code>index= 0 
index+1= 1 
index= 2
index+1= 3
index= 1
index+1= 2 
</code></pre>

<p>where it should have been:</p>

<pre><code>index= 0 
index+1= 1 
index= 1
index+1= 2
index= 2
index+1= 3
</code></pre>
