JavaScript variable scope inside a loop

I got stung because I forgot (once again) that JavaScript does not have block scope. Doh! So I hope writing this down (even if it is embarrassing) will help me remember for next time.

A loop such as this:
for (i = 0; i < 10; i++) {
var x;
if (Math.random() > .5) x = i;
will not yield occasional empty x values, as one might expect. In JavaScript, having a variable declaration within the for-loop block does not reset the variable's value, as it would in languages that do have block scope.