operands then applies strict
comparison. If either operand is a
number or a boolean, the operands are
converted to numbers; if either
operand is a string, the other one is
converted to a string.
What's actually happening is that the strings are being converted to numbers. For example:
1 == '1' becomes
1 == Number('1') becomes
1 == 1:
Then try this one:
1 == '1.' becomes
1 == Number('1.') becomes
1 == 1:
If they were becoming strings, then you'd get
'1' == '1.', which would be false.
It just so happens that
Number('') == 0, therefore
0 == '' is true and this happens in your case. So when you explicitly parse as parseInt($find('cid46890').get_value()) as given in my code, the variable fish has value NaN (Not a Number) if the textbox is empty and case(fish==0) wont get executed since NaN not equals 0 and the code works properly as expected.