Hacker News new | ask | show | jobs
by ArbitraryCrow 4782 days ago
I have very little experience with Javascript. I come from a Python background. So please excuse my ignorance, but this doesn't sound like a designed language feature at all. These look like tricks that programmers discovered they could use to provide namespace separation.

Wouldn't it better if there were constructs built into the language to provide separate namespaces, in an obvious and coherent fashion?

1 comments

In the browser, you have the global scope in the window object o it's pretty easy to define a construct for namespaces.

I thought about the namespaces thing and it sounds like a better idea than encapsulating stuff into anonymous functions so I made a little boilerplate that implement basic OOP features:

http://jsfiddle.net/L4Tcw/21/

Only thing that I think smells a bit is having to keep a reference to 'this' of the main object.