Image.onerror comes with a handler, not an error message, url, ...
So, the first item in the argument list is an event.
If you try your code with
image.onerror(errorMsg, url, lineNumber, column, errorObj) { console.log(errorMsg); console.log(url) }
you should get an event for the first log and undefined for the second.
I was unable to find any legitimate link regarding what comes with the burdensome handler for the Image object. But it seems that it is mainly used to flag errors for the user, not for the developer.
Akshar
source share