DEV Community

Discussion on: Improve your JS skills with those tips #2

Collapse
 
codeoz profile image
Code Oz

Hey I miss I mean "side effects " 😅! I think benchmark is not the good approach about this, the focus is on "side effect" that can be leads by delete operator. In general in programming we don't encourage people to remove property from a current object since some "logic" can be linked to this property and lead to bug.

For the example you highlight, I mean that the if condition can be avoid, so we should avoid it when we can. In this case we have only one condition and only one property. Imagine that we need to add 10 properties with 10 conditions differents, you will use 10 if?

I'm agree that short circuit don't need to be abusing but it can lead to less DRY (don't repeat yourself).