Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
What is the difference between null and undefined in Javascript?
Home
JavaScript
What is the difference between null and undefined in Javascript?
asked
Oct 1, 2023
in
JavaScript
by
GeorgeBell
What is the difference between null and undefined in Javascript?
javascript-interview-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Oct 1, 2023
by
GeorgeBell
Below are the main differences between null and undefined,
Null
Undefined
It is an assignment value which indicates that variable points to no object.
It is not an assignment value where a variable has been declared but has not yet been assigned a value.
Type of null is object
Type of undefined is undefined
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.
Indicates the absence of a value for a variable
Indicates absence of variable itself
Converted to zero (0) while performing primitive operations
Converted to NaN while performing primitive operations
...