Why does JS alert execute before console.log when a loop is following the statements
<p>I have a JS code snippet which I use to introduce pause between calls being made. The snippet is:</p>

<pre><code>function intPause(_wg_time_msec) {
    var _wg_now = new Date();
    var _wg_expire = _wg_now.getTime() + _wg_time_msec;
    while(_wg_now.getTime() &lt; _wg_expire)
        _wg_now = new Date();
}
</code></pre>

<p>Now what I see is that if add an alert to this function before the while loop, it shows the alert instantly and then runs the while loop, but if I add a console.log instead of alert, console.log echoes the data after while loop completes. Can someone please help me in understanding this behavior and how can I get a better way to introduce pause between calls.</p>
