DEV Community

Discussion on: What you need to know about Javascript's Implicit Coercion

Collapse
 
elarcis profile image
Elarcis

Only case where I like to use type coercion is with null.

There are only two values that == null : null and undefined. Same thing for undefined. So it's very useful for when you want to check if your variable holds an actual value and want to avoid an ugly (variable === null || variable === undefined), just do variable == null.

Collapse
 
promisetochi profile image
Promise Tochi

nice tip @elarcis