Search This Blog

Tuesday, July 6, 2010

Difference between Undefined value and null value.

Undefined states that variable has been declared but not defined yet i.e. not assigned a value yet.

while null is an assignment value. where variable has no value it assigns null to that variable
null is an assignment value. It can be assigned to a variable as a representation of no value.

undefined is a type itself (undefined) while null is an object.
Unassigned variables are initialized by JavaScript with a default value of undefined.
JavaScript never sets a value to null. That must be done programmatically.

No comments:

Post a Comment