I have 2 arrays and I want to filter one of the arrays with another array.
2 arrays designed like this
array1= [{id:23},{id:11},{id:435}]
array2= [23, 435, 5]
I want to check and get items only if id of objects inside array1 is equal to one of the ids (string values ) in array2
I found a simple solution like this
var filtered=[1,2,3,4].filter(function(e){return this.indexOf(e)<0;},[2,4]);
but my case is a bit different, I dont know how to make return part, how can I get indexes of each array ?
var filtered=array1.filter(function(e){return e.id === ??},array2);