Is there a method like includes that only searches for an element in an array but allows you to see the elements that are being iterating on?
for example: I have the following array:
const arr = [{ color: 'red' },{ color: 'blue' },{ color: 'pink' },{ color: 'green' }]
I want to check if the arr
holds an element with the value of pink
: so I thought if there's something like this in JavaScript:
arr.includes( (el, index)=> el.color == 'pink' )
which then returns a boolean, either true or false.
Is there a method like that in JavaScript? if not, what about lodash?