In addition it is true that null is a value that must be assigned, rather than a value such as that is the undefined value. The thing about undefined is that it is often the assumed default for variables that have been declared but not assigned anything, it is also a value that is obtained for object keys that have not been defined also.
- Source code examples are up on Github
1.1 - null must be assigned.
One major difference to undefined is that the null value must be assigned to a variable or object property. By default the undefined value is what the value of an variable that is declared but has not been assigned anything. Same is true of object properties, and what is returned by a function, in any case the null value must be assigned.
1.2 - In some cases null can be set as a value, but undefined can not.
In some cases it is possible to set an argument to null, but not to undefined. For example many functions are designed in a way in which there is a default value that is assigned to an argument when do argument is given. Often this works by testing for the undefined value by way of strict type equality. In the event that the argument is undefined a default value is assigned for the argument, so it can not be set to undefined, but it can be set to null.
2 - Typeof null is object.
So when the typeof operator is used to find the type of a value that is null, the result is an object.
Without a check for nul then what will result is an error when trying to access a property of null.
3 - Adding one to null vs doing the same with undefined
One note worthy difference between null and and undefined is what happens when you add a number to null compared to doing the same with an undefined value. When adding a number to an undefined value the result is NaN, where doing the same with a null value will result in the number that was added to null. For this reason alone it might be better to use null as a define value fo sorts compared to undefined.
4 - Conclusion