Javascript Array.prototype.filter() not working

Array.prototype.filter does not change array inplace, it returns new array made of items that satisfies the provided predicate. It should look like this

var result = eventList.filter(function(event) {
    return res.find(function(visibility) { return visibility.ID == event.id; }) === undefined;
});

You don’t need to declare and assign variable and then return it from function, you can simply return expression

Leave a Comment