null
in javascript is an object, which has few important, arguably confusing implications. Unfortunately JS has two ways to declare that something is "nothing", and the default way to do so is undefined
.
Having two ways to declare that something is "nothing" might be confusing and could be unnecessary. I can't come up with a use-case where I'd need two (and Douglas C. thinks the same), therefore we should pick one or another.
Below is why I think we should pick undefined
and not null
:
We have plenty of code like this: