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.



You May Interest

What is Code Smell in Javascript ?

JavaScript How To Find The Average Of 10 Numbers Using A While Lo ...

What is this Keyword in Javascript ?

JavaScript Making Lowercase

JavaScript Using While Loop