5 Tips to Write Better Conditionals in JavaScript

When working with JavaScript, we deal a lot with conditionals, I have 5 tips to share with you for writing better / cleaner conditionals.

  1. Use Array.includes for Multiple Criteria
  2. Less Nesting, Return Early
  3. Use Default Function Parameters and Destructuring
  4. Favor Map / Object Literal than Switch Statement
  5. Use Array.every & Array.some for All / Partial Criteria

As usual. please read the full article👇in scotch.io, code samples provided (free of course, with better syntax highlight).