How i am getting long keep on in the setTimeout?
<p>How this code works? any one help me to understand ?</p>

<pre><code>var myArray = ['one','two','three'];

var logAll = function (){
    var long = myArray.length;
    for(i=0;i&lt; long;i++){
        console.log(myArray[i]);
    }
    setTimeout(logAll,50);
}
logAll();
</code></pre>

<p>According to me, the myArray length is just 3, so, my log has to give me the result as 0,1,2. thats ok. out of my for loop i introduced a setTimeout for logAll function, but how that logAll function keep on calling the for loop instead of 3 times, to ever..? any one help me to understand this?</p>

<p>if so, why this is calling only one time ?</p>

<pre><code>var myArray = ['one','two','three'];

    var logAll = function (){
        var long = myArray.length;
        for(i=0;i&lt; long;i++){
            console.log(myArray[i]);
        }

    }
    setTimeout(logAll,50);
</code></pre>
