I'm discovering odds of JavaScript comparisons. I wanted to find an example of how tricky comparisons may be, and how can cause bugs in some situations.

I thought about example where some input variable remains undefined, and is compared to zero. Because undefined is false when converted to Boolean, and zero is false when converted to Boolean I decided to test following code:

```
var x;
//Here x should be initialized but due to some circumstances is not
if(x == 0){
   //This should run
}

```

Surprisingly...

```
Boolean(undefined) //false
Boolean(0) //false
x //undefined
x == 0 //false

```

Why it's like that?