Run function in closed enviroment
<p>How can I run code so that the code itself cannot access my main code on the <code>window</code> variable?</p>

<p>For example:</p>

<pre><code>var popup = function(msg){ alert(msg); };

(function(){
    window.x = 5;
    popup("hi."); //does not work
})();

alert(x) //does not return 5
</code></pre>

<p>I'm trying to write a code tester. I've been reading about scopes and classes, but I'm not understanding them enough to figure this out.</p>

<p>Thanks in advance!</p>
