DEV Community

Discussion on: A neat little trick with JavaScript's indexOf()

Collapse
 
cschliesser profile image
Charlie Schliesser

I'd much rather my code be readable and explicit. Converting -1 to falsy and all other indexes to true seems like more work - just check the index that you're looking for, or use another method like Set.has or Array.includes if that's what you're trying to check. My opinion :)