It seems to be the case at least here on StackOverflow that Hungarian notation is most often considered to be a bad thing (though a minority are still in favour).
Now in the JavaScript world where I've been doing most of my coding for the past few months seems to have embraced a naming convention which is in essence very similar yet I haven't seen anyone arguing against it, that is UpperCamelCase
to name object constructors vs lowerCamelCase
to name everything else.
So the differences seem only to be at the surface:
Some people like to state that "systems Hungarian" is different from "applications Hungarian" where the former indicates types and the latter indicates things which types don't cover. In this case "systems Hungarian" is usually still considered bad while "applications Hungarian" may be considered good.
The JavaScript camel casing convention seems more like systems Hungarian so wouldn't gain any merit on that point.
The points people argue against Hungarian notation seem to still apply to JavaScript object constructors:
So what is different about this JavaScript convention that makes it OK where the more general Hungarian notation is not OK?
Is it lack of good JavaScript IDE? Does its limited area of use make it not so bad? Is it due to dynamic languages not really having much in the way of types? Is it just not a problem since it can't get overused?
(If this belongs on programmers.SE rather than SO please migrate.)
It is more like "applications Hungarian" after all.
Javascript doesn't know whether your function is a constructor or a plain function. And calling a constructor as if it was a plain function may lead to a quite odd undesired outcome (unless you're using ES5 strict mode).
I don't see how IDE will help you there either. The only thing IDE could do is to prevent you from calling var x = new plainFunction();
and var y = Constructor();
, which implies using the Hungarian notation first.
I don't see how using the notation makes the code harder to read either.