0

I have a function main that has several inner functions like this:

function main_f (params) {
    function do_this () {
        // do this...
    }
    function do_that () {
        do_this(); // working
        main_f.parse_stuff(); // not working
        parse_stuff(); // not working
    }
    do_that();
    main_f.parse_stuff = function(){
        console.log("success");
    }
}
function second_f () {
    main_f.parse_stuff(); //working
}

I was expecting that main_f.parse_stuff() would work inside do_that, but that is not the case. My questions are:

-Is it posible to call that method from inside main_f ? how?

EDIT: Execute do_that after parse_stuff is written.

-Why can't I call parse_stuff from main_f?

EDIT: I just realised that the function doesn't read on compilation time, but execution time, therefore it is not visible when do_that is called.

-How can I know every function on scope?

Vandervals
  • 5,774
  • 6
  • 48
  • 94
  • I found what was wrong, I think. As main_f doesn't read before execution, the call was being made before the function load. Anyway, I'd like to know how to get the functions available in that scope, if possible.ç – Vandervals Jun 29 '15 at 08:46
  • 1
    Your remaining question is simple, you can't iterate over the scope to see what's inside. – Ja͢ck Jun 29 '15 at 08:51
  • Why is it not possible? – Vandervals Jun 29 '15 at 08:52
  • 2
    Perhaps [this answer](http://stackoverflow.com/a/2051693/1338292) will help you on the why. – Ja͢ck Jun 29 '15 at 08:57

1 Answers1

0

It is not possible by programation but you can do it with the debugger. Just insert a break point on that scope and you can check everything that is global, local and in the closure.

I checked this with chrome dev-tools.

Vandervals
  • 5,774
  • 6
  • 48
  • 94