My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

What's the best alternative to indexOf() for checking existence of element in an array?

James B's photo
James B
·May 11, 2016

In most languages, indexOf() returns -1 if element is not found, which IMO is a bit counter productive. What's the best alternative to this in you programming language? Is there any function that will just return a boolean value indicating if the element was found?