Data Types - Null and Undefined
Null
- Null is a special value indicating that they variable has no value
what so ever.
- Null is not equal to 0 nor "" (the empty string)
Undefined
- A variable with the data type of undefined is a variable that has been
declared, but never given a value.
- Variable with undefined values can not be used in calculations.
Try the following program out.
var x;
var y = null;
var z = "";
document.write("x= " + x + "<P>");
document.write("y= " + y + "<P>");
document.write("z= " + z + "<P>");
if (y==z) document.write("y = z<P>");
Run the above program.
Try adding the statement
if (x == y) document.write("x = y<P>");
Run with the modification.
Back