Hacker News new | past | comments | ask | show | jobs | submit login

The defacto standard is to put nothing in an enclosing namespace unless it's needed there. The purpose of functions (especially in a language like JS) is to wrap up everything that's needed to accomplish a given task and leave no mess behind.



Then why oh why are variables global by default? (this is not meant as an attack on your point, I fully agree, I just find this awfully frustrating about JS. Sane languages have scoped by default and a global keyword, not the other way around)


You'd have to ask its designer. Sloppy programmers do like globals and JS was targeted for them.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: