Stop using if/switch, use objects instead

  1. Straight up Dry
With if condition
replace with JS Object

--

--

--

Senior Software engineer. In love with JS and all its realm. Night owl and often write at weird times.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Docker — Three Ways To Create Container Images and Their Use Cases

React, Redux, and Rails

Understanding redux-saga: From action creators to sagas

Development Environment Setup Angular, Nodejs — Javascript Version

Just Finished a Paid Career Path, Am I a Web Developer Now?

How to optimize your CSS/JAVASCRIPT code?

Announcement: IDE Tooling for AngularDart 5

How to build an advanced Modal in React (Part One)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Raghav

Raghav

Senior Software engineer. In love with JS and all its realm. Night owl and often write at weird times.

More from Medium

What is API ….!! simple explanation

MobX vs Redux: Comparison — Which Performs Better?

Abstraction, Interfaces, and World Building — Part 2

Setting profiler and flame-graph in Visual Studio Code