DEV Community

Discussion on: 5 ways to refactor if/else statements in JS functions

Collapse
 
merri profile image
Vesa Piittinen

Tip: instead of something === undefined && something === null you can write something == null and it matches both undefined and null, and only them.

I find it the only valid case to use == over ===.

Collapse
 
drarig29 profile image
Corentin Girard

That's true, but oftentimes you have a linter which forces to use "eqeqeq"

Collapse
 
merri profile image
Vesa Piittinen

Only if you have had someone strongly opinioned setting it up :) And even then you have the null: ignore option for it.

Collapse
 
sylwiavargas profile image
Sylwia Vargas

True! Thanks!