What is the purpose of the script scope?
<p>When inspecting scopes of a function in the DevTools console I noticed a "script" scope. After a bit of research it seems to be created for <code>let</code> and <code>const</code> variables.</p>

<p>Scopes of a function in a script without <code>const</code> or <code>let</code> variables:</p>

<p><a href="https://i.stack.imgur.com/FmM8R.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FmM8R.png" alt="the global scope"></a></p>

<p>Scopes of a function in a script with a <code>let</code> variable:</p>

<p><a href="https://i.stack.imgur.com/ob2mV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ob2mV.png" alt="a global scope and a script scope"></a></p>

<p>Yet the following prints <code>1</code> in the console - variables in the script scope can still be accessed from other scripts:</p>

<pre class="lang-html prettyprint-override"><code>&lt;script&gt;let v = 1&lt;/script&gt;
&lt;script&gt;console.log(v)&lt;/script&gt;
</code></pre>

<p>I've heard of ES6 modules in which top-level variables won't be accessible from outside a module. Is that what the scope is used for or does it have any another purpose?</p>