if/else block - but it is also more flexible than
if, because it can check for any value of the switching variable - and not just true or false.
case is often used in React applications in Redux reducers - which are often big functions with a single switch/case, which represents the entire function.
Summary of Content:
- Defining a simple switch statement and a few case blocks
- Preventing "fall through" with
- Switch checks against value and type (===)
defaultto provide a default return value from switch/case