DEV Community

Discussion on: What is the oddest JavaScript behavior?

Collapse
 
bergamin profile image
Guilherme Taffarel Bergamin

The weirdest thing for me in JS is the fact that you will only know if something works at runtime because there isn't any compilation.

This brings weird stuff like the undefined state. It is basically telling you that you are using something that doesn't exist. You know it should exist at that point, but because of some mistake somewhere you cannot identify because there is no compilation, you will have to check if that shit is undefined before checking if it is null before checking if it is empty.

Yes, I'm new to JS and I know you can test any variable as if they were Boolean to check for undefined and null, but I think that's not readable enough, so I would rather create a function with another name that checks for that.