Javascript - Why do method variables survive within a callback?
<p>Say you have [<a href="http://jsfiddle.net/Wrz6X/" rel="nofollow">Fiddle</a>]</p>

<pre><code>function TestMethod() {
    var lifespan = "blah";

    $.ajax({
        url: "http://www.google.com",
        success: function (data) {
            alert(lifespan);
        },
        error: function (errorData) {
            alert(lifespan);
        },
        dataType: 'html'
    });
}
</code></pre>

<p>Why is it that <code>lifespan</code> still exists when the callback fires?  What else persists through asynchronous calls?  What allows this to happen, is there some kind of "runtime" ,if you will, in javascript that keeps code alive during the process?  If so, when does it know when to start letting in memory items die?</p>
