Declaring Prototype Inside of Object Literal
<p>I am creating an object literal, which I'm using as a namespace.  The object literal (namespace) happens to contain a constructor function, MyConstructor.  I want to extend the   prototype of MyConstructor, inside the object literal.  If I pull the declaration for MyConstructor out and put it above the declaration of myNamespace, all is well, except MyConstructor is no longer namespaced by myNamespace.  How best to make this work?  The following fails to compile because<br>
 of the '.' in this line:    </p>

<pre><code>MyConstructor.prototype = {
</code></pre>

<p>Object literal provided below.  </p>

<p>Thanks,
Mike</p>

<pre><code>var myNamespace = {
    a:  3,
    b: function (msg) {
        alert(this.a);
    },
    MyConstructor: function(xx) {
        this.x = xx;
    },
    MyConstructor.prototype = {
        a: 1,
        b: function() {
            return true;
        }
    }
};
</code></pre>

<p>Update:  The accepted solution works.  However, the very premise of my question was flawed.  I would not use an object literal at all in this situation, because it is harder to unit test, as I found out.  Instead, I would use a normal object created with a constructor, and put the private objects inside it.  Another thing is, a "self/immediately executing function", while beautiful in some ways, is a bit harder to explain to a newbie.  </p>
