http://wiki.ecmascript.org/doku.php?id=harmony:private_name_objects
I would like to avoid reifying the names of private properties (as variables
holding name objects). Wouldn’t it be enough if they were private relative to
the current class/constructor? Then the following would work (strawman syntax):
function MyClass(pwd) {
this[private(MyClass, "pwd")] = pwd;
}
MyClass.prototype.isPwd = function(pwd) {
return this[private(MyClass, "pwd")] === pwd;
}
Another consideration: private methods are sometimes helpers that have to be
unit-tested. Thus, one should be able to access them “from outside”. That’s
something you can’t do if you use a closure for private data.
--
Dr. Axel Rauschmayer
[email protected]
twitter.com/rauschma
home: rauschma.de
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss