I need help understanding why the following piece of code returns an undefined object property: 

```
var count = 0;
var intervals = {
    collection : []                      
}

intervals.collection[0] = function () {
    this.timer = setInterval(function(){
       count++;
       $("p").html(count);            
    }, 1000);
}();

if(typeof intervals.collection[0] === "undefined") {
    $("span").html("undefined");        
}​

```

Working Example: <http://jsfiddle.net/tvaQk/8/>

Basically, I'd like to be able to keep a collection of setIntervals that I can reference later so I can loop through and clear. I was thinking I'd be able to loop through the intervals.collection array and do something like:

`clearInterval(intervals.collection[0].timer)`

but cannot since `intervals.collection[0]` is undefined