DEV Community

Discussion on: NULL VS UNDEFINED IN JS

Collapse
 
bias profile image
Tobias Nickel

In my opinion you should always use undefined. because it is the natural value.
When a prop is not there, it is undefined. When ever you see a null value, that means a developer put it in place.

Also most often I don't care. because I write if ( myValue ) { ... }. It will work in both cases. just need extra condition if it could be an empty string or 0. For going into the positive case.

You wrote a nice documentation around the topic. What is your opinion?

Collapse
 
jaynil profile image
Jaynil Gaglani • Edited

Yeah, we shouldn't put null deliberately. Undefined is normally easy to handle as well in conditionals.