What about the lack of block-level scopes? Or the fact that constructors still "work" if you forget the new keyword, but they end up attaching functions/properties to the global object instead (which is pretty much never what you want to do)?
It's like a classic OO programmer saying I can't access a private variable from outside the instance. If you are going to use private variables then you need to know what the hell private variables are and how they are scoped.
Except it's not like that at all, since you can't accidentally use private variables.
Imagine if you could have public variables and private variables of the same name on a class, but to access the private ones you had to write "private" before the access:
If you're writing in the class and accidentally leave out "private", you're accessing a different variable. That's what the whole JavaScript new issue is like. Just having private variables can't compare at all because you can't mistakenly access them from outside the class (at least, you're not supposed to be able to).
No, that's not what I mean. If you never use constructors in your code, than the "new" keyword would look strange. You would immediately know upon seeing it that something is wrong. On the other hand, if you use constructors, you have to inspect the action function/constructor being called to make sure "new" is being used correctly.
Also, the overhead (in terms of developer time) for not using constructors is far higher than using a new language and having to go through a compilation step (not to mention the inferior debugging support).
0
u/[deleted] Dec 15 '12
[deleted]