Nesting JavaScript Objects
<p>I am writing a simple JavaScript application.  The code consists of creating an object <code>deck</code> which can have many nested <code>card</code> objects.</p>

<p>Basically, I wanted to be able to access each card in a deck instance like this:</p>

<pre><code>deck1.card2.method();
</code></pre>

<p>I have used the following function to create my deck prototype:</p>

<pre><code>function Deck(){
var cardStack = []
//deck properties &amp; methods
}

function card(){
//card properties methods
}
</code></pre>

<p>I've been adding each card to the deck and storing them in the <code>cardStack</code> array, using <code>push</code> and <code>pop</code> methods of JavaScript arrays.</p>

<p>This however does not allow me to access my cards as I wished to do:</p>

<pre><code>deck1.card2.method();
</code></pre>

<p>Can anyone point me in the right way to achieve this?  Is it possible in JavaScript?  Thank you in advance :-)</p>
