Lets say i have an array filled with objects like this:
{conversation_id: 38
id: 99
is_seen: 1
message: "Hej Kristina"
timestamp: "2015-07-08T10:50:49.000Z"'
}
Now I wish I could find out how many of these objects has the value is_seen set to 1 and conversation_id set to 38.
I could solve this by using a forEach loop, however I am looking for a solution that is cleaner and maybe even more efficient.
My application is an AngularJs application, so I'm looking for either native JavaScript or Angular ways to solve this.
Array.filter(). Something along the lines of:my_array.filter(function(el) { return el.conversation_id == 38 && is_seen == 1; }).length;