I have a function defined inside another function like so:
var bar;
function foo() {
bar = function() {
// This should output the full source code of foo()
}
}
bar();
When I call bar(), it should output the full source code of foo(), the function in which it is defined, to the console. What code should go inside bar() to achieve this behavior?
After I have that part accomplished, how would I look further up the chain to see what function foo() was defined in (and so on and so forth), by only calling bar()?
Thanks!
Edit: please don't answer with unconstructive replies such as "you shouldn't be doing this" or "you'll never need this." If I didn't need it I wouldn't be asking.