Hacker News new | ask | show | jobs
by user2459 5203 days ago
It's all about scope. What you should do is read about scope in javascript and get to know it well. Then stuff like this will come naturally or you'll at least understand why people program like this and that it's not just some language peculiarity.

MDN: https://developer.mozilla.org/en/JavaScript/Reference/Functi...

short stack overflow: http://stackoverflow.com/questions/500431/javascript-variabl...