DEV Community

Discussion on: Check item is already exists in an array using JS

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

A boolean is unnecessary since values have truthiness and falsiness - -1 will become a falsy value (0), everything else will be truthy (negative numbers). Converting manually to a Boolean is inefficient and unnecessary

Thread Thread
 
devshetty profile image
Deveesh Shetty

Oh yeah that's true, didn't think of that way.

Thank you!