Reputation: 1165
I have an array of objects, something like this example:
var b = [
{
'super_attribute[170]': "41",
'super_attribute[171]': "15",
'data': 1
},
{
'super_attribute[150]': "401",
'super_attribute[181]': "5",
'test': 1234
}
];
I want to select the object out of the array that has the attribute
and value
values from a
var a = {
'super_attribute[170]': "41",
'super_attribute[171]': "15"
};
Is this possible with array filters or mapping?
Upvotes: 0
Views: 68
Reputation: 5437
var filtered = b.filter(function(item){
return item.attribute == 'something' && item.value == 1;
});
edit: here you'll find the documentation to filter
Upvotes: 2