Lets say I have a selector $('.items') and I want to get every item except those that are contained within an array of jQuery item objects.
I could use filter or grep or each to go through every item selected, and on every item i could make another loop to see if it matches any in the disallowed array.
I am just wondering if there is either a shorthand way of doing this, or a more efficient way? What do you think is the best way of implementing this?
Use
filteras it’s the most readable way, and it’s the the purpose of the function-filter…eachused mainly to do actions on each element in the set.grepis for arrays, not jQuery objects, though it can be done with it, it shouldn’t.How I would do it: