how do variables work in Javascript? Can variable Value change during setTimeout?
<p>I have the following code:</p>

<pre><code>function Notification(type) 
{
    switch (type) 
    {
        case "success":
           notificationID="not1";
           break;
        case "error":
           notificationID="not2";
           break;  
    }

    setNotificationTimeoutId = setTimeout(function () {
        jQuery('#' + notificationID).fadeOut(200, function () {
            var notification = document.getElementById(notificationID);
            if (notification) 
            {
                jQuery(notification.parentNode).remove();

                if (type == "success")
                        DoSomething();
            }

            setNotificationTimeoutId = null;
        });
    }, 5000);
}
</code></pre>

<p>My question is, if the function(Notification) gets called on a click event, and if it gets called two times(first with Notification("success") then with Notification("error")) by two click events, is it possible that the second function call changes the type variables value for the first function call? </p>

<p>For example: when the first call(one with success) enters the function inside the setTimeout(a second call to Notification already been made with type = "error") it sees the variable 'type' as "error" even though this call was the first and it wass called with type = "success"?</p>
