The difference between undefined and null is as follows,
1-When we declare any variable and we do not give it a value then it will have the value undefined.Undefined is a type all to itself
2- We can declare a variable and can set it to null.JavaScript do not set anything to null, only we can declare any variable to null. When you're debugging the code then you can see that anything that is set to null is of your own doing and not JavaScript.
We can also compare a variable which is undefined to null and the condition will be true.
For Example:
undefined == null
null == undefined
Undefined Example -:
var a = [ 'a', 'b', 'c' ];
delete a[1];
for (var i = 0; i < a.length; i++)
WScript.Echo((i+".) "+a[i]);
The output for the above script is:
0.) a
1.) undefined
2.) c
0 Comment(s)