If you are looking for a single result in an array, you can use Array.prototype.find() instead. This will return the first element that satisfies the condition, or undefined if no such element exists. If you don't mind mutating the original array, it can be significantly faster than the previous one.

2m read timeFrom 30secondsofcode.org
Post cover image
Table of contents
Find a single valueRemove a single valueAdditional notes
2 Impressions