Javascript (using jQuery) in a large Project... organization, passing data, private method, etc
<p>I'm working on a large project that is organized like so:
Multiple javascript files are included as needed and most code is wrapped in anonymous functions...</p>

<pre><code>// wutang.js

//Included Files Go Here

// Public stuff
var MethodMan;

// Private stuff
(function() {

var someVar1;

MethodMan = function(){...};

var APrivateMethod = function(){...};

$(function(){
//jquery page load stuff here
    $('#meh').click(APrivateMethod);
});
})();
</code></pre>

<p>I'm wondering about a few things here. Assuming that there are a number of these files included on a page, what has access to what and what is the best way to pass data between the files?</p>

<p>For example, I assume that <code>MethodMan()</code> can be accessed by anything on any included page. It is public, yes? </p>

<p><code>var someVar1</code> is only accessible to the methods inside that particular anonymous function and nowhere else, yes? Also true of <code>var APrivateMethod()</code>, yes?</p>

<p>What if I want <code>APrivateMethod()</code> to make something available to some other method in a different anonymous wrapped method in a different included page. What's the best way to pass data between these private, anonymous functions on different included pages? Do I simply have to make whatever I want to use between them public? How about if I want to minimize global variables?</p>

<p>What about the following:</p>

<pre><code>var PootyTang = function(){
    someVar1 = $('#someid').text();
    //some stuff
};
</code></pre>

<p>and in another included file used by that same page I have:</p>

<pre><code>var TangyPoot = function(){
    someVar1 = $('#someid').text();
    //some completely different stuff
};
</code></pre>

<p>What's the best way to share the value of someVar1 across these anonymous (they are wrapped as the first example) functions?</p>
