title: can I turn off optimization, so in-scope variables from closures aren't "optimized out"
body: <p>As a byproduct of code optimization done by modern browsers, while debugging, you can't "see" all variables which "factually" are in scope. This is well known and has been addressed in a <a href="https://stackoverflow.com/questions/28388530/why-does-chrome-debugger-think-closed-local-variable-is-undefined">previous question here on SO</a>. This feature, while most certainly useful in production is annoying me a lot during development, it slows me down (that should be obvious.)</p>
  
  <p>Now my question is, is there any way to turn off this behavior? Can I edit some configuration file, or is there a browser plugin, or maybe there is a "special build version for developers" of the browser executable? I love typing my code into the console right away when I'm writing new code, so this is really bugging me.</p>
  
  <p><a href="https://i.stack.imgur.com/SiaHY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SiaHY.png" alt="visualSummaryIffalseConsoleLog"></a></p>
  
  <p><strong>UPDATE / EDIT</strong></p>
  
  <p>Here is a partial solution, credit to Paul1365972.</p>
  
  <p>You have to start the chrome browser from the command line, with special options, like so:</p>
  
  <ol>
  <li>Close Chrome completely</li>
  <li>Run Chrome from console with <code>"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe" --js-flags="--allow-natives-syntax"</code> 
  that's for windows other OS similar.</li>
  <li>Open developer console and execute <code>"%GetHeapUsage()"</code>. If you properly started Chrome with the option, a number will be logged to the console, otherwise you'll get a syntax error.</li>
  </ol>
  
  <p>With this command line flag, you can 'talk to the V8' engine with commands starting with <code>%</code>, which are syntax errors in plain JavaScript. A list to available V8 commands of this kind was <a href="https://gist.github.com/totherik/3a4432f26eea1224ceeb" rel="noreferrer">given in Paul's answer</a>.</p>
  
  <p>There is <code>%NeverOptimizeFunction()</code> on that list, which is something which looked like the thing I'd just have to call and be done with it. Unfortunately, that function does not do what I hoped for, as demonstrated in next screenshot.</p>
  
  <p><a href="https://i.stack.imgur.com/onTSs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/onTSs.png" alt="lorem still not defined"></a></p>
  
  <p>(((The <a href="https://www.npmjs.com/package/v8-natives" rel="noreferrer">other link from Paul's answer</a> (v8-natives node module) is of no importance to us here in this context. All it does is it wraps one-liners around the "%" function calls so the code doesn't crash browsers which are not v8.)))</p>
  
  <p>(((I remember a time when this worked (when this optimization wasn't invented/implemented yet). I don't know how long ago. Ten years? 15 years? Something like that. What was the last Chrome version (if any) and what was the last firefox version (more sure here that it exists) where you could do? It won't get you the bounty, but it will get you an upvote, if you happen to know and post it as an answer.)))</p>
  
  <p><strong>THE SOLUTION</strong></p>
  
  <p><strong>THANK YOU PETR SRNICEK</strong></p>
  
  <p><a href="https://i.stack.imgur.com/GVfkD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GVfkD.png" alt="hacky fix"></a></p>
  
  <p><strong>NEW QUESTION</strong></p>
  
  <p>While Petr's solution helps a lot, it is not perfect. This question is getting too long, so I posted a <a href="https://stackoverflow.com/questions/59159996/how-do-i-go-into-evaldebugger-mode-when-already-stopped-at-regular-debugge">new question</a> on how Petr's solution can be improved. (I could of course edit this question here, but that would feel "unhistorical", if you know what I mean.)</p>