title: Event Listener and AJAX asynchronous function variable scope
body: <p>I got a question, probably very simple, but whatever. When registering an event listener inside an asynchronous function, I would believe that all values within that function would be non-existing when the function has run it's course.</p>
  
  <p>However, an event listener, as displayed below in the code can still access the variable <code>values</code>, how is that? Is the variable saved within the event listener somehow?</p>
  
  <pre><code>$.ajax({
      type: "GET",
      cache: false,
      url: "/whatever",
      success: function(data) {
          var values = ["Some Values", "Inside this Object"];
  
          $("#id :checkbox").click(function() { 
              var allValues = [];
  
              $('#id3 :checked').each(function() {
                  allValues.push($(this).val());
              });
  
              $("#id2").val(allValues);
  
              callMe.init(values,allValues);
          });
      }
  });
  </code></pre>