can I turn off optimization, so in-scope variables from closures aren't "optimized out"

Google Chrome uses the V8 JS-Engine, you can enable native calls to it with the --allow-natives-syntax flag, this exposes many useful debugging functions (full list here) like the one you are looking for: %NeverOptimizeFunction(). Without this flag, these calls would be illegal syntax so be careful when deploying (or use the v8-Natives library).

To enable this feature just open chrome with --js-flags="--allow-natives-syntax" (only use this for debugging of trusted websites, as this can give untrusted js code access to things you really do not want it to have access to).


You can get access to all variables by wrapping the debugger statement in an eval like this: eval("debugger;");. This hacky solution adds another anonymous function to the call stack though and it is obviously of no use for breakpoints that are set manually in DevTools.

This does not seem to be a very good solution, but since it is the only one that achieves the intended behaviour so far, I am posting it as an answer.