Learn all about the jQuery function jQuery.grep().
$.grep() method removes items from an array as necessary so that all remaining items pass a provided test. The test is a function that is passed an array item and the index of the item within the array. Only if the test returns true will the item be in the result array.
The filter function will be passed two arguments: the current array item and its index. The filter function must return ‘true’ to include the item in the result array.