Don’t Use If-Else and Switch in JavaScript, Use Object Literals

Write better conditionals in JavaScript with object literals

Jack Taylor
Better Programming
Published in
3 min readApr 12, 2021

--

Question mark next to a closed door
Photo by Jac Alexandru on Unsplash.

Writing complex conditionals in JavaScript has always had the potential to create some pretty messy code. Long lists of if/else statements or switch cases can get bloated quickly.

--

--

I am a UI developer writing about JavaScript, React and tech in general. Currently working at Pleo.