Re:Using the switch(true) pattern in JavaScript
by notyourday on Monday April 12, 2021 @11:11AM
(#26780255)
If you don't have a 'return' there's nothing to say that some time later some junior developer would not modify throw to be something else or forget that throw does not return.
[ Parent
| on HN ]
Re:Using the switch(true) pattern in JavaScript
by dfee on Monday April 12, 2021 @11:25AM
(#26780410)
This will prevent the JR dev from making that mistake: https://eslint.org/docs/rules/no-fallthrough
Re:Using the switch(true) pattern in JavaScript
by BiteCode_dev on Monday April 12, 2021 @11:49AM
(#26780778)
That's what tests are for.