Pass reference of main object to another object
<p>I created this simplified version of some code I'm dealing with. I need to figure out how to pass a reference of an instantiated object to another object that has been created by this object. I can't get the reference to the main object "self" to be passed to the second object and actually be able to call a function on it. Hopefully the code will make it more clear:</p>

<pre><code>var app = app || {};
(function (m, $, undefined) {

    m.Counter = function () {
        var self = this;
        var pub = {};

        pub.total = 0;

        pub.add = function () {
            pub.total++;
        };

        pub.subtract = function () {
            pub.total--;
        };

        pub.status = function () {
            console.log(pub.total);
        };

        pub.spawn = function () {
            var sp = new app.modules.Obj(self);
            return sp;
        };



        return pub;
    };

    m.Obj = function (counter) {
        var pub = {};

        pub.add = function () {
            counter.add();
        };

        return pub;
    };

}(app.modules = app.modules || {}));

var c = new app.modules.Counter();

c.add();
c.add();
c.add();
c.status();

d = c.spawn();
d.add();
c.status();
</code></pre>

<p>What I would want to have happen is that d.add() would increment the total of c. So the output would be 3 for the first c.status() call and then 4 for the output of the second c.status();</p>
