1var item,
2 i = 0,
3 groups = {},
4 year, day;
5while (item = eventsArray[i++]) {
6 item = new Date(item.date);
7 year = item.getFullYear();
8 day = item.getDate();
9 groups[year] || (groups[year] = {}); // exists OR create {}
10 groups[year][day] || (groups[year][day] = []); // exists OR create []
11 groups[year][day].push(item);
12}
13