It can sometimes be difficult to go to a loosely typed from language from a strongly typed one. Especially with conditionals. I hit this issue today where I had it in my mind that the variable was an integer but the javascript runtime treated it as a boolean. To code phrase the issue:

function test(v) {
    return v || 1;
}
var value = test(0);

Usually that kind of OR is a quick check if the variable being passed in is undefined or null and then set the second value as the default. In this case the 0 is a concrete number, the problem is that the javascript compiler treats it as a boolean and zero resolves to false in the conditional. This means the returned value is 1. Not much fun when you are expecting the returned value to be an integer of 0.

It is a quirk of the Javascript language that many things will resolve to false; including undefined, null, 0 and "". In most cases this can be taken advantage of, except when it can't like I ran into today.
Cam Riley: South Sea Republic. Freedom, liberty, equity and an Australian Republic.