I have been using javascript for couple of years and never cared about the difference between null & undefined earlier, i always use undefined to validate the object existence.
But recently i came through this article. Here they said
JavaScript distinguishes between null, which is an object of type 'object' that indicates a deliberate non-value, and undefined, which is an object of type 'undefined' that indicates an uninitialized value — that is, a value hasn't even been assigned yet. We'll talk about variables later, but in JavaScript it is possible to declare a variable without assigning a value to it. If you do this, the variable's type is undefined.
I am completely confused now, what exactly is non-value here. how this non-value differs from undefined. And what are the circumstances javascript returns null.
I have tried the below sample
var sam;
alert(sam); // returns undefined
And
try{
//var sam;
alert(sam);
} catch(ex){} // ex says - sam is undefined
And i am not sure about when js returning nulls. can someone clarify me.
Cheers
Ramesh Vel