Today in “Things not to do when writing Javascript”

Wednesday, Jul 14, 2004, 00:00

Pop quiz: what’s wrong with this piece of code?

function foo() {
    var route = route();
    // ...
}

The answer: it won’t do anything. That’s because in Javascript, everything is an object, including functions and variables, and they all share the same name space. By declaring a variable called route in the current scope, the function route() from the surrounding scope is hidden.

I am not going to tell you whether I just wasted an hour on this stupidity. Oh no.