var TestVar;
alert(TestVar); //shows undefined
alert(typeof TestVar); //shows undefined
null is a special keyword that indicates an absence of value.
- "suresh" is string,
- true is boolean ,
- 1234 is number,
- null is undefined.
null
doesn't represent a string that has no value - empty string-
Like
var a = '';
console.log(typeof a); // string
console.log(a == null); //false
console.log(a == undefined); // false
Now if
var a;
console.log(a == null); //true
console.log(a == undefined); //true
But
var a;
console.log(a === null); //false
console.log(a === undefined); // true
undefined
use it to compare the variable data type
null
use it to empty a value of a variable