Different between filter() and find() in javascript

md ahnaf arshadmd ahnaf arshad
1 min read

filter() and find() is a javascript method. only use an array. The find() method return a specific one and the filter() method returns more than one.

find() method:

const x = [12, 12,12,12,12,12, 22, 11, 1112, 221]; const y = x.find(res => res !== 12 );

console.log(y)

output: [22]

filter() method:

const x = [12, 12,12,12,12,12, 22, 11, 1112, 221]; const y = x.filter(res => res !== 12 );

console.log(y)

output: [ 22, 11, 1112, 221 ]

0
Subscribe to my newsletter

Read articles from md ahnaf arshad directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

md ahnaf arshad
md ahnaf arshad