Accessing copied version of an object to modify?
<p>If I copy code into a closure like this</p>

<pre><code>(function(){
    var private1 = {},
        private2 = {},
        publik;

    publik.get(object){
         private1[object.name] = object;
    };

    window.publik = publik;
}())


publik.get({
    // API
    name: 'name_foo',
    functionA: function(){
        // I can not access private2 in here
    },
    functionB: function(){}
})
</code></pre>

<p>Is there a way the API can work, so that the functionA and functionB can have access to private 2 inside the closure.</p>

<p>They will be copied into the closure, so the copied version should have access to it.  That is why I made the closure and put private1 and private2 together like that.</p>

<p>The written version ( not the copied version ) of the object throws an error in jslint and my guess is that this is becasue it breaks scope rules.</p>

<p>The function argument ( not parameter ) is an un-named variable in the global scope and has no access to the closure.</p>

<p>( until is is copied into it :)</p>

<p>Would it work if I made <code>private1</code> and <code>private 2</code> the same object say...just <code>private</code>...and then accessed it using <code>this</code> keyword.</p>

<p><strong>I would prefer to keep them separate however.</strong></p>
