Javascript is great if you don't do oddball things with it. Nobody can rightly deny that there is a ton of potential to do stupid things with javascript. I'm sure someone could write out a line of [other language] code that is quite the head scratcher, and works as defined in the spec. If coffeescript works as a nice complete syntax re-do for you, that's good but you have to learn two programming languages in that case. I prefer raw js, auto-linted to help highlight any potential stupidity. In the supplied example, the var at the end of the function would be caught by the linter indicating that it leads to bugs and there is no good reason to do it - so don't.