Before anyone asks, I have already search existing questions and found this question, but the answer was that undefined
was being set to null
, which is not the case here.
Here is my code:
check_availability = function () {
var value = $('#contact_type').val();
if (value !== undefined) {
// do some stuff
}
}
Simple huh? I have a <select id="contact_type"></select>
with options populated via ajaxy stuff. Initially the options list is empty, so the jQuery val() returns undefined
.
So far so good.
Except that the code within the if
block always executes. I stick a breakpoint in FireBug on the 3rd line and I get this:
Can anyone tell me what's going on?
P.S. This is Firefox 4.0
EDIT: I know there are a number of ways I can achieve the same result, I'm more interested in why value is undefined according to FireBug, but then is !== undefined.