To filter array with multiple conditions with JavaScript, we call the filter
method.
For instance, we write
const filteredUsers = users.filter(
(obj) => obj.name === filter.name && obj.address === filter.address
);
to call users.filter
with a callback that gets the items with the name
property of the obj
being looped through equal to filter.name
.
And we get the item in users
with address
property equal to filter.address
.