Javascript: underfined value.

One my colleague was amazed about javascript behavior with undefined:
 undefined == null //true
Undefined behavior is tricky enought.
On my opinion, javascript engine treat undefined as null in most cases.
But it will throw error in case you directly user undefined variable, in case of undefined field - all okay:

 alert(ee); //ReferenceError: ee is not defined
 alert(window.ee); //alert Underfined
Possible, such behavior is nonsense!
But, I am suspect, that the first case was designed to warn a developer that he misspelled variable name.

Undefined type and its tricky behavior - are common part of all script and not-statically-typed languages.

I am even recall my amazed face many years ago about SQL NULL behavior:
"WHERE name = NULL" -- have different behavior in SQL ISO mode and non-ISO mode.
"WHERE name IS NULL" -- this works fine regardless ISO mode.
Links:

Comments