null and undefined difference
Many a times we often get confused on whats the difference between UNDEFINED and NULL.
undefined means a variable has been declared but has not yet been assigned a value.
On the other hand, null is an assignment value. It can be assigned to a variable as a representation of no value.
In JavaScript, == will compare for equality after doing any necessary type conversions while === will simply return if the two values are the same.
(null == undefined) -> true
(null === undefined) -> false
Comments
Post a Comment