for(laziness in javascript)

This post is mostly a note-to-self.

Compare the following pieces of javascript:

var list = ['a','b','c'];
for(x in list) {
   alert(x);
}
var list = ['a','b','c'];
for(**var** x in list) {
   alert(x);
}
 

Either works in Firefox. Only the one on the right works in IE. Hint: the difference is in bold.

The IE behaviour encourages you to define your variables and not get lazy. Given that I develop under Firefox and don’t test under IE until late in the day, remembering this one will be a huge time-saver.