array length property not found within javascript object prototype
<p>I am trying to create a simple javascript/html5 canvas engine to support my animation(this is mainly for learning purposes.)</p>

<p>Engine:</p>

<pre><code>/* BOF GLOBAL REFERENCES*/
var BM = BM || {};
/* EOF GLOBAL REFERENCES */

/* BOF GLOBAL VARIABLES */
/* EOF GLOBAL VARIABLES */

/* BOF FUNCTIONS */
BM.World = function(container,width,height,name){
    this.container = $("#"+container);
    this.width = width;
    this.height = height;
    this.name = name || "DefaultWorld";

    this.layers = new Array();
}

BM.World.prototype.Layer = function(options){
        var options = options || {};
        options.bgcolor = options.bgcolor || "transparent";
        this.container.html( "&lt;canvas id='"+this.name+"_layer_"+this.layers.length+"' style='position:absolute;top:0;left:0;width:"+this.width+";height:"+this.height+";background:"+options.bgcolor+";'&gt;"
                            +"&lt;/canvas&gt;");
}
/* EOF FUNCTIONS */
</code></pre>

<p>And the simple caller code:</p>

<pre><code>$(function(){
    var World = new BM.World("background_container",400,600);
    var layer1 = new World.Layer({bgcolor:"#ff0000"});
});
</code></pre>

<p>Can someone please tell me what I am doing wrong in the <code>Layer</code> definition? the error I get is:<code>Uncaught TypeError: Cannot read property 'length' of undefined</code></p>
