find() Method
This method is used to find the single item in the array. find() method return a single item that fulfill the condition which passes into the callback function.
let array = ['apple','orange','WaterMelon','Melon']
//apply find() method to the array
console.log(array.find((item) => item=='apple'))
returns --> apple
filter() Method
This method is used to find the multiple items in the array. filter() method return all those items which fulfills the condition that passes into the callback function.This method return a new array without modifying the original array.
let array = [1,2,3,4,5,6,7,8,9]
//apply filter() method to the array
console.log(array.filter((item) => item >=4))`
returns --> new Array [4,5,6,7,8,9]
Top comments (2)
difference is one returns first value and other returns an array.
example
great