title: how are callbacks being called after the fact?
body: <p>In the following code,  I don't understand why both callback functions are being called.  callback01 makes sense because it's in the callbacks array before the call to load.  callback02 on the other hand, it's not put into the array until after the call to load yet the console shows it being called.</p>
  
  <pre><code>var callbacks = [];
  
  function addCallback(func) {
    callbacks.push(func);
  }
  
  function load(img_url) {
    var img = new Image();
    img.onload = function() {
      console.log('loaded.');
      callbacks.forEach(function(func) { func(); } )
    };
    img.src = img_url;
  }
  
  addCallback(function() { console.log('callback01'); });
  load('img/image01.png');
  addCallback(function() { console.log('callback02'); });
  </code></pre>