I tried the following in JavaScript (Firefox 3.5, Windows XP):
(function(){
window.foobar = 'Welcome!';
})();
var foobar = 'PWN3D!';
alert(foobar);
The output was 'PWN3D!'. Why did my code PWN me? I thought var name = value; executed first.