我正在寻找一种管理集合集合的方法。请参见下面的示例代码:
function Collection() {
this.items = []; //Contains items, which have a date associated with them
}
Collection.prototype.doSomethingOnItems = function(){};
function SuperCollection() {
this.collections = []; //An array of Collection objects
this.group = []; //A vector with a string that designates the group (e.g. 2013, 2012)
}
SuperCollection.prototype.groupCollections = function(items, groupType) {
//Group by year, month, day, etc...
//For example, given a timeframe of 2012-2013, items in 2012 are put in collections[1], those from 2013 are in collections[2]
}
有没有更好的方法来管理这样的结构?