You can refactor switch statements to an object, making the syntax cleaner and more declarative.
This technique is very trivial, though worth mentioning. Since the value is already a boolean, it can be directly checked in the if.
We can also club multiple if checks in an array and then can check for the presence of those conditions in that array.
If we have multiple if-else conditions and the behavior of each condition is different, we can use lookup tables. We can also do the same using switch statement, however using lookup approach is more clean and crisp, IMO.
Many times we want to check variables values for undefined or null. It is a very common scenario in all types of application.
We can use ternary operators to call functions directly based on conditional expression.
Syntax of Spread operator is three dots …