Javascript - Array of 'classes'
<p>I'm trying to create an array of 'classes' like so:</p>

<pre><code>function Main(initURL){

    var item_array = [];

    this.initURL = initURL;

    function construct() {
        $.ajax({ 
            url: initURL,
            dataType: 'json',
            success: function(data){
                for(var i=0;i&lt;data.length;i++){
                    var item = new Item(data[i]);
                    item_array.push(item);
                }
                init();
            }
        });
    }

    function init() {
        setInterval(update, 1000);
    }

    function update() {
        for(var item in item_array){
            console.log(item.name);
        }
    }

    construct();
}

function Item(data) {

    var dirty = false;

    function init(data) {
        this.id = data.pk;
        this.name = data.fields.name;
    }

    init(data);
}
</code></pre>

<p>When attempting to print out the item name, I'm getting "undefined". Is there more to it than this? Data.field.name is definitely set. </p>
