4 ms·
I'm not sure where the opposition to private is coming from, outside of being anti-additional-syntax. Private variables already exist in Javascript. They're jus
by reissbaker 15y ago
I'm not sure where the opposition to private is coming from, outside of being anti-additional-syntax. Private variables already exist in Javascript. They're just inefficient, because they mean that any of an object's instance methods that reference them have to be declared inside of the class's constructor function, instead of on the prototype.
Private variables may be accessible outside of classes in Ruby -- but they already aren't in JS. And JS has extremely strong encapsulation through scoping and closures, so arguments against encapsulation based on the "language grain" fall a little flat for me. If an explicit private keyword enables optimization of existing functionality, then why not have one?