DEV Community

SHIJU G
SHIJU G

Posted on

Difference between find and filter method in javascript?

Top comments (5)

Collapse
 
d3xter profile image
Adrian Jakob • Edited

Find allows you to get a single (also the first) element from a array matching your condition while filter returns all elements matching your condition.

Collapse
 
shijug profile image
SHIJU G

thanks @adrian Jakob

Collapse
 
shijug profile image
SHIJU G

thanks @lukeshiru

Collapse
 
lexlohr profile image
Alex Lohr

Find stops after the first match and returns that or undefined if there is none, filter always returns an array of all matches or an empty one if there are none.

Collapse
 
shijug profile image
SHIJU G

Thanks @alex Lohr