Many a times we often get confused on whats the difference between UNDEFINED and NULL. You'll get to know the difference.
undefined means a variable has been declared but has not yet been assigned a value.
When a Variable is declared but no assigned, then it I undefined. For example:
let age; // declared but not assigned alert (age); // output is undefined
Below, a variable was declared which is age but was not assigned to any value. The output will then be undefined. The Code above states that the age is undefined.
On the other hand, null is an assignment value. It can be assigned to a variable as a representation of no value.
let age = null; // variable assigned to null alert(age); // output is null
Here you declared a variable "age" and assigned it to the value of null. Which means the value is unknown or empty. The above code will then output null since the variable is assigned to a value unknown.