What is Difference Between Undefined and Null in Javascript ?
The undefined means a variable has been declared but has no value has yet been assigned.
On the other hand, null is basically a value which has been assigned. Also, undefined is a type itself (undefined) while null is an object.
Unassigned variables are initialized with a default value of undefined by JavaScript or undefined can be assigned to variable through code. Whereas JavaScript never sets a value to null. That must be done programmatically.