I would first use something like Lodash's _.groupBy() to create an object where the key is the date (as a formatted string or string of the numeric value) and the value is an array of objects with the same date.
Then iterate over the object and if the value array has more than one element, do something with it.
e.g. if using Lodash (assuming your array of objects is called array):
var grouped = _.groupBy(array, function (obj) { return '' + obj.start.getTime(); });
_.each(grouped, function (objects, date) {
if (objects.length > 1) {
doSomething(objects);
}
});
If not using Lodash/Underscore, you can just roll your own grouping function:
function groupBy(collection, callback) {
var output = {};
angular.forEach(collection, function (obj) {
var groupKey = callback(obj);
if (!output[groupKey]) {
output[groupKey] = [obj];
} else {
output[groupKey].push(obj);
}
});
return output;
}
// to use it:
var groupedByDate = groupBy(array, function (obj) { return '' + obj.start.getTime(); });
angular.forEach(groupedByDate, function (objects, date) {
if (objects.length > 1) {
doSomething(objects);
}
});