access object from other scope (javascript)
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/11192875/is-it-possible-to-gain-access-to-the-closure-of-a-function">Is it possible to gain access to the closure of a function?</a>  </p>
</blockquote>



<p>Please have a look at this code: <a href="http://jsfiddle.net/FH6pB/1/" rel="nofollow">http://jsfiddle.net/FH6pB/1/</a></p>

<pre><code>(function($) {
  var o1 = {
    init: function() { alert('1'); },
  }
  var o2 = {
    init: function() { alert('2'); },
  }
}(jQuery));

(function($) {
  var o3 = {
    init: function() { alert('3'); },
  }
  o2.init();
}(jQuery));


o1.init();
o2.init();
</code></pre>

<p>I have 3 object in 2 different "scopes" (I don't know if it's the right word to use here, but I guess you understand the meaning).
As you probably know, I can't access the objects' function from either outside or other "scope" (non of the <code>o.init();</code> will work).</p>

<p>Why does it happen? Is there a way to change it?</p>

<p>I know I can just put the code in one scope and it will work well, but what if I have scopes in separate JS file?</p>

<p>Thanks from advance, 
Ben</p>
