Aryan PrajapatKnowledge Contributor
What is the difference between null and undefined
What is the difference between null and undefined
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Questions | Answers | Discussions | Knowledge sharing | Communities & more.
Below are the main differences between null and undefined,
Null
It is an assignment value which indicates that variable points to no object.
Type of null is object
The null value is a primitive value that represents the null, empty, or non-existent reference.
Indicates the absence of a value for a variable
Converted to zero (0) while performing primitive operations
Undefined
It is not an assignment value where a variable has been declared but has not yet been assigned a value.
Type of undefined is undefined
Indicates absence of variable itself
Converted to NaN while performing primitive operations
The undefined value is a primitive value used when a variable has not been assigned a value.
undefined means a variable has been declared but has not yet been assigned a value, whereas null is an assignment value, meaning that a variable has been declared and given the value of null .