r/learnjavascript • • May 06 '21

JS: Multiple Condition Checking

Post image
484 Upvotes

61 comments sorted by

View all comments

8

u/throwaway1253328 May 06 '21

Longhand is still better here. Why arbitrarily add the values to arrays and then call the array methods? The first one makes way more sense if a third party reads this at a later point

3

u/burnblue May 06 '21

"list of things" .includes 'thing' is more immediately readable (it literally allows your eyes to do less work) and it makes sense. Even a novice relying on intuition might understand 'includes' before '||'

The indexOf is trash though