> > > I don't think I've ever heard an active JavaScript developer, who has > been programming in JavaScript longer than 6 months, ask for private class > or instance variables. > > Your own code: > > https://github.com/mikeal/npmjs.org/commit/c0d9cc77e79504b9a7c23b4fac735dde97444054#L3R10 > Line 35, you define the function stopBuffering (keeping only relevant > parts): > ---- > function File (options) { > > var stopBuffering = function () { > // ... > } > > } > ---- > Why didn't you do this.stopBuffering = function(){}? > > Maybe you used the keyword "var", but you effectively created a private > method of your "File" class. With a class syntax, you would have used the > "private" keyword to achieve the same thing. > Maybe you don't call it this way, but you use (and de facto ask for) > privacy. >
I think making such broad statements as "every local variable is actually a 'private' variable" is just plain silly. To me that looks like a utility method for code organisation points. "private" means its a private method/data that's used in other methods of an object. That particular function is not used in any method. And no, with class syntax it would not be private, it would still be a utility function inside the constructor. I personally second that we don't need private or instance variables.
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

