Javatpoint Logo
Javatpoint Logo

Difference between Null and Undefined


Null is used to represent an intentional absence of value. It represents a variable whose value is undefined. It accepts the one and only value null. The Null keyword is used to define the Null type in TypeScript, but it is not useful because we can only assign a null value to it.



It represents uninitialized variables in TypeScript and JavaScript. It has one and only value that is undefined. The undefined keyword defines Undefined type in TypeScript, but it is not useful because we can only assign an undefined value to it.


Null vs Undefined

SN Null Undefined
1. It is an assignment value. It can be assigned to a variable indicating that a variable points to no object. It is not an assignment value. It means a variable has been declared but has not yet been assigned a value.
2. It is an object. It is a type itself.
3. The null value is a primitive value that represents the null, empty, or non-existent reference. The undefined value is a primitive value used when a variable has not been assigned a value.
4. Null indicates the absence of a value for a variable. Undefined indicates absence of variable itself.
5. Null is converted to zero (0) while performing primitive operations. Undefined is converted to NaN while performing primitive operations.

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA