I\'m just curious to know
Is there ANY ways in ANY browser to find out where the alert I get is raised from?
I tried it in chrome but there is no call stack availabl
There is a trace function is console is provided by all major browsers. console.trace();
With Proxy approach, as described in earlier answers, and console.trace(), we can print the entire stack with line number in console itself.
(function(proxied) {
window.alert = function() {
console.trace();
return proxied.apply(this, arguments);
};
})(window.alert);
This is an IIFE. Every alert call will have its trace printed in the console.