# JavaScript: `filter()` method

.filter() is a built-in array method that is used to filter out the elements of an array based on specific condition.

\=============================================================

The filter method calls a `callback` function on each element of array on all indexes. The function need to return a `boolean` value `true` or `false` based on certain conditions. Based on which the function decides whether to include the certain element or not.

The `callback` function creates new `array` with all elements for which the function returns the condition as `true` , and elements for which the function returns condition as `false` are simply ommitted out and not included in the new `array` that is created.

For Example:

In this example, we have array of `studentsParticipating`, We want to delete `studentsStepDown` from array and output the filtered array without `studentsStepDown`.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1677683674465/f44ed719-50bb-4fd0-9f7b-3964dfa27ebc.png align="center")

  
Now, let's say we have an more than one student stepping Down, so now we have `studentsStepDown` array, we need to remove it's elements from `studentsParticipating` and return in new array `LatestStudentsParticipating`.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1677688722689/d8252c50-3cb0-44e2-8b64-ce6c6009b301.png align="center")

Thanks for reading
