DEV Community

SHIJU G
SHIJU G

Posted on

5 1

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

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay