filter() method returns a new array filtered down to just the elements that pass a test provided by a function.
syntax ↴
filter(callbackFn) A function to execute for each element in the array ↴
function is called with the following arguments ↴
filter(function(element, index, array), thisArg) ↴
callback function allows access to each element, the index, and the original array itself.
thisArg (optional). Value to use as this when executing callbackFn. By default, it is undefined.
filter() method returns an array of elements that pass the test.
filter() method returns an empty array [] if no elements pass the test.
filter() method does not execute the function for empty elements.
filter() method does not change the original array.
myArray.filter(callbackFn)