I'm just starting to get deeper in JavaScript programming, in particular OO and prototyping, and have run into a problem. I want to create some 'container' objects with themselves contain 'item' objects...

function container() {
   this.width = '400';
   this.height = '600';
   this.color = 'white';

function item() {
   this.heading = 'Item';
   this.text = 'Default item text';

var containerA = new container();
containerA.color = 'red';

var containerB = new container();
containerB.color = 'green';

// I want these in containerA.
var itemA = new item();
var itemB = new item();

// I want these in containerB.
var itemC = new item();
var itemD = new item();
So now I have two 'container' objects and four 'item' objects. How would I go about adding itemA and itemB to containerA, and itemC and itemD to containerB?

I have some ideas... perhaps I need some sort of item array var in the container object? Or perhaps I need a parentContainer var in the item object. Then if I loop through them I can programmatically add them.

I would like to be able to shift items to other containers also.

I hope this is making sense and someone can offer me some guidance!