DEV Community

Discussion on: A New Coding Style for Switch Statements in JavaScript/TypeScript

Collapse
 
aifwd profile image
ai-fwd

Is there a good reason to allocate entry at all in this scenario? My guess is you’re doing it for demonstration purposes but it’s overly verbose otherwise.

Collapse
 
nebrius profile image
Bryan Hughes

Correct, this was for demonstration purposes, and I agree that in practice I'd just inline the call in this case. I'll tweak the examples to make this more clear, thanks! My actual code that prompted me to write this did 3 things with the entry variable.