Javascript gives us different functions when searching through arrays. Two of them are: includes
and some
. But what is the difference between them?
includes
returns a boolean when there is at minimum an element in the array that is equivalent to the value that is being searched for or if it fails to find the element. It uses equalTo
comparator when going through the array.
some
also returns a boolean whether at minimum an element in the array that is equivalent to the value that is being searched for or not, but it does this by allowing a callback function to be used where you can define your own logic.