How do I give multiple JavaScript objects across multiple files access to same private variable?
<p>If I want to span my JavaScript project across multiple source files, but have each file have access to the same private variable, how would one do that?</p>

<p>For example, if I have the following code:</p>

<pre><code>APP = (function () {
    var _secret = {},
        app = {};
    // Application part 01:
    app.part01 = (function () { /* function that uses _secret */ }());
    // Application part 02:
    app.part02 = (function () { /* function that uses _secret */ }());
    //
    return app;
}());
</code></pre>

<p>How do I put <code>app.part01</code> and <code>app.part02</code> in seperate files, but still have access to _secret?
I don't want to pass it as an argument. That's just giving the secret away, as <code>app.part01()</code> could be replaced by any other function.</p>

<p>Maybe I am asking the impossible, but your suggestions might lead me in the right way.</p>

<p>I want to work with multiple files, but I don't know how. Copying and pasting everything inside a single function each time before testing is not something I want to do.</p>