One question that often puzzles me is how JavaScript still retains a reference in a callback function of an AJAX request, even when the variable was declared in the function that issues the AJAX call. Here's an example:
var loadMask = {name:"test"};
form.submit({
url: 'request.php',
timeout : 180000,
success: function(the_form, action_object)
{
console.log(loadMask);
}
});
Despite loadMask being declared outside of the success function, it remains visible and defined inside.
How does this work?