📜  javascript 数据结构 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:11.053000             🧑  作者: Mango

代码示例2
var item,
    i = 0,
    groups = {},
    year, day;
while (item = eventsArray[i++]) {
    item = new Date(item.date);
    year = item.getFullYear();
    day = item.getDate();
    groups[year] || (groups[year] = {}); // exists OR create {}
    groups[year][day] || (groups[year][day] = []);  // exists OR create []
    groups[year][day].push(item);
}