

Encapsulation in JavaScript - dabent
http://www.neeraj.name/blog/articles/879-encapsulation-in-javascript

======
seasoup
I've been developing javascript for web applications and large consumer web
sites for 10 years. Functional to OO to JSON notation. The ability to create a
private function is a neat theoretical exercise, but the amount of code or
change in coding patterns necessary to implement private functions is complete
overkill.

Unless you are developing a huge javascript driven application, it does not
actually matter if a method is private or public. Just don't call it. Much
simpler/cleaner code, easier to read, easier to maintain. I'm a big proponent
of making code simple instead of complex and private functions in javascript
just add complexity.

Now, although I am skeptical, I would love to hear other commentors experience
where they found private functions in javascript to be invaluable. What have
you coded where making a method private added value to your code making it
worth the increased complexity?

