My code looks like this:
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';
});
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?