What is the difference between undefined value and null value? Undefined value: A value that is not defined and has no keyword is known as undefined value. For example in the declaration, int number; the number has undefined value.
Null value: A value that is explicitly specified by the key word ‘null’ is known as null value. For example in the declaration, String str=null; the str has a null value. The keyword ‘null’ is used here. What is the difference between undefined value and null value? - Null value has keyword called ‘null’. That is not the case with undefined.
- typeof undefined variable or property returns undefined whereas typeof null value returns object.
|