Always use === not ==. Double equals does something called type coercion, meaning JavaScript quietly converts types before comparing them. So 0 == false returns true. That is almost never the result ...