JS is so easy to cock up in, I commonly find myself logging to the console just to make myself sure of the scope and other things.<p>This technique totally went to shit when I came across one of our scripts that gratuitously used `apply()` all over the place.<p>The other common error is array iteration, and I've not quite understood why iterating through one array in the same scope as where it was created works fine, but passing it to another function and performing the exact same routine also goes through the prototype methods after the elements.<p>Of course, particularly with the var mistake, you'd never really understand the magnitude of it until you attempted to use JS on the server side. This post has, quite thankfully, likely exposed a bug in my own code I couldn't quite understand a while ago. :)