You can assign null to a variable to denote that currently that variable does not have any value but it will have later on. A null means absence of a value
When we define a variable to null then we are trying to convey that the variable is empty
var myVaAr = null; alert(myVarA); // null
In the above example, null is assigned to a variable myVarA. It means we have defined a variable but have not assigned any value yet, so value is absence.
A null value evaluates to false in conditional expression. So you don’t have to use comparison operators like === or !== to check for null values.
Example: null in conditional expression
var myVarA = null; if (myVarA) alert("myVarA is not null"); else alert("myVarA is null" );
The type of Undefined is undefined.
When we define a variable to undefined then we are trying to convey that the variable does not exist .
var temp; if(temp === undefined) console.log("true"); else console.log("false");
Output is: true
Accessing values which does not exist
var temp=['1','2','3']; if(temp === undefined) console.log("true"); else console.log("false");
Output is : true