Brief introduction:
I\'m attempting to get at line number of function definition for parsing documentation comments on only public stuff. I\'ve gotten to the point
Here's a potential solution that I haven't tested. A couple years ago, there was a security exploit that allowed JavaScript to redeclare constructors of native objects. John Walker gave this example:
function Array() {
this[1] = 50;
}
var a = [40];
alert(a[0] + a[1]); // Gives 90
In the same vein, perhaps it's possible to redeclare the function declaration in the browsers where the exploit exists?
function Function() {
// Should give the stack trace, complete with line number?
alert(new Error().stack);
}
window.x = function () {}
I don't have the necessary browsers (John Resig cites Firefox 2, Opera 9, and Safari 3 as browsers where the Array exploit works), so I can't test it, but maybe this is a place to start?