So, title says most of it, and I’ll give an example:
var foo = ['one', 'two', 'three'];
var bar = [
{
integer: 1,
string: 'one'
},
{
integer: 3,
string: 'three'
}
];
Now, I’m wondering how can I get the list of positive matches for each of the elements in foo against each of the string properties of all the objects in array bar.
First, make a set of all elements in
footo avoid square complexity:Then, go through
barand gather matches:After this,
matchesarray will contain the elements frombarthat match the elements offoo.Here’s a live example: