Enclosure Memory Copies
<pre><code>function myClass()
{
  //lots and lots of vars and code here.

   this.bar = function()
   {
     //do something with the numerous enclosed myClass vars
   }

   this.foo = function()
   {
      alert('Hello'); //don't do anything with the enclosed variables.
   }
}
</code></pre>

<p>Each instance of myClass gets its own copy of bar and foo, which is why prototyped methods use less memory. However, I would like to know more about the memory use of inner methods. </p>

<p>It seems obvious to me that (1) below must be true. Do you agree? </p>

<ol>
<li>Not only do distinct myClass instances have their own distinct copies of bar, but they also must have their own distinct copies of the myClass enclosure. (or else how does the bar method keep the myClass variables straight on a per instance basis?)</li>
</ol>

<p>Now (2) is the question I'm really after.</p>

<ol>
<li>Since the inner foo method doesn't use anything in the myClass enclosure a natural qustion is: Is javascript smart enough to not keep a myClass enclosure in memory for the use of foo? </li>
</ol>
