|
I like the comparative approach with C#, as it helps ensure more and more people can appreciate the support JavaScript provides for writing good code.
But when the author suggests that "JavaScript does not support any concept of method or property visibility: every property and method is always public", well... he's completely wrong.
Sure, it may not have some nice built-in way to do that (although you could argue prototype isn't nice either), but there is plenty of experience in data hiding in JavaScript, both at instance and class level (static variables and functions).
For reference, you can have a look at http://www.crockford.com/javascript/private.html, but there is much more around. You may also want to look at a post on my blog where I compare several different approaches, and I also provide links to more people who have solved this problem: http://www.webcom.it/blog/articles/2006/05/24/private-static-members-in-javascript
Andrea
|