title: backbone custom properties for collection
body: <p>So I'm trying count my models in my collection by the category they have.</p>
  
  <p>This is my code:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>App.Collections.channls = Backbone.Collection.extend({
      model:    App.Models.Channel,
      catCount: new Array(),
  
      initialize: function() {
        this.bind('add', this.onModelAddedd, this);
      },
  
      onModelAdded: function( model, collection ) {
           if (this.catCount[model.get('category_id')] == undefined) {
             this.catCount[model.get('category_id')] = 0;
           }
           this.catCount[model.get('category_id')]++;
      },
  
      returnCount: function() { return this.catCount }
  });
  </code></pre>
  
  <p>I initialize this collection a couple of times.</p>
  
  <p>The problem is that when I get the <code>catCount</code> property of the collection, the array acts like a global variable. So it didn't only count the models from its own instance of the collection, but the array is counting all the models that are added over <em>all</em> the instances of the collection.</p>
  
  <p>Anyone know how to make a property of a collection only count towards its own instance?</p>