Finds the elements of an array which satisfy a filter function. The original array is not affected.
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.
Arguments:
| array | Array | |
|---|---|---|
| The Array to find items in. | ||
| callback | Function | |
The function to process each item against. The first argument to the function is the list item, and the second argument is the list index. The function should return a Boolean value. The "lambda-form" function feature was removed in jQuery 1.2.3 to help compatibility with other frameworks.
function callback(indexInArray, elementOfArray) {
var shouldKeepIt;
this; // == window
return shouldKeepIt;
}
| ||
| invert (Optional) | Boolean | |
| If "invert" is false, or not provided, then the function returns an array consisting of all elements for which "callback" returns true. If "invert" is true, then the function returns an array consisting of all elements for which "callback" returns false. | ||
