I'm trying to improve an old React web application for work when i stumble upon this variable:
const condition = (
param !== const1 && param !== const2 && param !== const3 && ...
)
Is there a best practise to improve this very long and condition?
The idiomatic way of performing such check if you're checking running the
!==comparison for all items you should use theArray.everyfunctional predicate.It checks that every item matches the condition: