Why same code works and does not work in another form
<p>I have two javascript codes . 
Two codes working for the same work , but there is one code work and the other code does not work .</p>

<p><strong>Work</strong></p>

<pre><code>var i = 0;
function slideShow(){
    i++;
    document.getElementsByName('SearchBox')[0].value = i
    setTimeout(slideShow, 1000);
}
</code></pre>

<p><strong>Not work</strong></p>

<pre><code>var i = 0;
function slideShow(){
    setTimeout(function(){
        i++;
        document.getElementsByName('SearchBox')[0].value = i
    }, 1000);
}
</code></pre>

<p>Why one works and the other does not work</p>
