M
matty
Hi,
I recently got very confused (well that's my life) about the
"undefined" value. I looked in the FAQ and didn't see anything about
it. On http://www.webreference.com/programming/javascript/gr/column9/
they say:
<snip>
The undefined property
A relatively recent addition to JavaScript is the undefined property.
It's useful when you want to test whether a variable has been
initialized or not.
var a;
if ( a == undefined ) a = "some value";
</snip>
Is this really valid? Shouldn't it be "if (typeof a == 'undefined') ?
Would an explanation on what "undefined" is and how to check for it be
a good entry for the FAQ?
Thanks,
Matty.
I recently got very confused (well that's my life) about the
"undefined" value. I looked in the FAQ and didn't see anything about
it. On http://www.webreference.com/programming/javascript/gr/column9/
they say:
<snip>
The undefined property
A relatively recent addition to JavaScript is the undefined property.
It's useful when you want to test whether a variable has been
initialized or not.
var a;
if ( a == undefined ) a = "some value";
</snip>
Is this really valid? Shouldn't it be "if (typeof a == 'undefined') ?
Would an explanation on what "undefined" is and how to check for it be
a good entry for the FAQ?
Thanks,
Matty.