I have an array of object having multiple attributes. I have a requirement to filter the array based on many attributes. lets say all the objects having firstname as "John" and who lives in "India" and "30" years of age.
I have done this by putting && condition after each filtering, but I am planning to use Underscore.js in my project. Please let me know if Underscore.js can help me write in a more elegant manner?
Json Data:
{
"recordsTotal": 5,
"recordsFiltered": 5,
"aaData": [
{
"firstname": "John",
"lastname": "Kumar",
"city": "Dhaka",
"country": "Bangladesh",
"age": "30"
},
{
"firstname": "John",
"lastname": "Wells",
"city": "Katmandu",
"country": "Nepal",
"age": "28"
},
{
"firstname": "Praveen",
"lastname": "Garg",
"city": "columbo",
"country": "Srilanka",
"age": "40"
},
{
"firstname": "Joe",
"lastname": "Wells",
"city": "Luton",
"country": "UK",
"age": "12"
},
{
"firstname": "Rita",
"lastname": "Wahlin",
"city": "houston",
"country": "USA",
"age": "28"
}
]
}