title: How to return from an async function
body: <p>My code looks like this:</p>
  
  <pre><code>myObject.myMethod('imageCheck', function () {
      var image = new Image();
      image.onerror = function() {
          return false;
  
      };  
      image.onload = function() {
          return true;
      };
      image.src = 'http://www.example.com/image.jpg';         
  });
  </code></pre>
  
  <p>But, it doesn't work, assumedly because my returns only return from the anonymous function, not from the one called imageCheck. How can I rewrite this so that the whole function is returned as true or false?</p>