0% found this document useful (0 votes)
0 views5 pages

Filter Method Js

Uploaded by

Gaurav Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views5 pages

Filter Method Js

Uploaded by

Gaurav Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

   


   
Filter Method is an array method
that Returns a New Array filled
with the Elements that Pass the
Filter Condition.

Let’s understand with a real-life example.


Imagine principal of a school wants to meet
some students of 10th standard who have got
less than 60% marks. So he sends the peon to
the classroom and the peon then asks the
students who have got less than 60% marks
and takes them to the principal.

Here the principal is Filter method, peon is the callback


function & the classroom is an array.

Students Peon Principal


(Array) (Callback Function) (Filter Function)

Here’s the Code Example


In this example, we want to get the elements from the arr
(array) that are more than 30. To do this, we applied .filter()
method to the array and passed the filter condition that is
(num)=> return {num>30} in the callback function. As a result,
the filter function returns a filteredArr that contains the
elements that we want.
Found
this Helpful?
Like, Comment &
Share this Post

You might also like