DEV Community

Discussion on: JavaScript undefined and null: Let's talk about it one last time!

Collapse
 
oliverradini profile image
OliverRadini

Just out of interest, has anyone had this kind of thing affect them in any actual work? It seems to come up in interview questions etc. but I've never had it cause any kind of problem.

Collapse
 
atapas profile image
Tapas Adhikary

One way I think I have faced it..

Whenever I have written something like,

if (!age) {

}
Enter fullscreen mode Exit fullscreen mode

I was sure, it ruled out undefined and null too. Knowing it gives additional confidence, :)!

Collapse
 
hermannp profile image
hermann-p

To be exact, it will also rule out NaN, "", '', and -- very error prone -- 0.

Thread Thread
 
atapas profile image
Tapas Adhikary

Yeah true.. all those unwanted things! :)