DEV Community

Discussion on: 17 Javascript optimization tips to know in 2021 🚀

sneakycrow profile image
Zachary E. Sohovich

These tips are really good.

Generally, I feel that using switch statements is most of the time not necessary, and using an object is very much a good alternative and one that is commonly available.

That being said, I think number 9 is misleading. You stated that objects are shorthand for switch statements, and they aren't. They're an alternative you could do sometimes. But saying an object is "shorthand" for a switch statement is definitely not correct.
There are definitely situations where you would need a switch statement instead of an object (IE, the object cannot replace the switch statement). A shorthand of syntax should be able to replace the original in all situations.

I think just modifying the text to state that its not a shorthand but an alternative that's commonly available would be good.