javascript closure: protecting inner variable
<p>I'm using the revealing module pattern somewhat like this:</p>

<pre><code>var SomeClosure = function () {

  var SomeInnerVar = 4;

  function InnerGetTheVar() {
     return SomeInnerVar;
  } 

  function InitClosure() {
       // there's something else happening here that requires me to 
       // wait for document.ready before initializing the closure
       setInterval(IncreaseSomeInnerVar, 10000);
  }

  function IncreaseSomeInnerVar() {
     SomeInnerVar = SomeInnerVar  + 1;
  }

  InitClosure();

  return  {
     GetTheVar: InnerGetTheVar
  }
}

$(document).ready(function () {

   SomeClosure = SomeClosure();
}); 
</code></pre>

<p>Now why is it that if in the console I type this:</p>

<pre><code>SomeClosure.GetTheVar = 2;
SomeClosure.GetTheVar; // outputs 2!
</code></pre>

<p>Why doesn't the closure keep <code>SomeInnerVar</code> protected? I don't want the outer scope to be able to change SomeInnerVar like that.</p>

<p>Thanks for your suggestions.</p>
