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 Alert Method in Window Object in Javascript ?

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

What are Advantages of Javascript ?

What is Console Object in Javascript ?

How to Handle Exceptions in JavaScript ?