Difference between undefined and null
Can someone explain to me what the difference is between undefined and null?
NULL is a special value which represents nothing or empty. You can initially set a variable to NULL. For example:
let fname = null;
Maybe we don’t know the name yet. Later we can change it.
fname = "John";
The variable below is undefined:
it is undefined because a value hasn’t been assigned to it yet.
Null is an assignment value, it is assigned to a variable, as seen above.