Share
Difference between undefined and null
Question
Hi,
Can someone explain to me what the difference is between undefined and null?
Thanks
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Answer ( 1 )
NULL is a special value which represents nothing or empty. You can initially set a variable to NULL. For example:
Maybe we don’t know the name yet. Later we can change it.
The variable below is undefined:
it is undefined because a value hasn’t been assigned to it yet.
Null is an assignment value, it is assigned to a variable, as seen above.
We have an article about Javascript data types, check it out.