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 Event Capturing in Javascript ?

What are Asynchronous Scripts in Javascript ?

What is Alert Method in Window Object in Javascript ?

What are Control Flow Statements in Javascript ?

What are the Variable Naming Conventions in JavaScript ?