I’d like to see a way to access local variables of an IIFE, without breaking into code in the IIFE’s scope. Is there some way to convince the debugger to do this?
If you're entering a breakpoint from a function called by the IIFE, you can just walk up the stack. If you're outside the IIFE entirely, I don't think it's possible The variables you're looking for may not even exist in memory, either before or after execution. Javascript doesn't have static variables like other languages do, so each time the IIFE is called, the variables inside it are thrown out. Javascript is also very much single-threaded (unless you use web workers and such, which come with limited interactivity with their parent pages) so unless you're trying to race-condition yourself with an async/await call, I don't think there's even a way to conceptually have these variables around in memory outside the IIFE scope.
You could (ab)use `var` to initialize the variable outside the IIFE scope so you can see the values produced by the last IIFE call.
You can basically wander around any function context at any arbitrary time and see what happened. It exploits the reference counter to keep the contexts from being destroyed. It was really great back when I did a lot of client side js
The killer app version of this would be to open a repl at any context. As it stands it requires a good bit of competency to do it well.
Not really. Suppose I have access to a closure that was created by the invocation of an IIFE. I would like to access variables that are in scope as seen from inside the closure, and I’d like to do this without executing the closure.
In Chrome you can inspect your closure (as you clarified in https://news.ycombinator.com/item?id=38226743#38231705) using the "Watch" pane, and then look at its "[[Scopes]]" pseudo-property. I don't think there is a way in Firefox.
https://en.m.wikipedia.org/wiki/Immediately_invoked_function...