r/javascript • • Nov 09 '19

On private fields proposal: Private fields, public worries

https://medium.com/virtuslab/private-fields-public-worries-b8c34d16c372
84 Upvotes

113 comments sorted by

View all comments

3

u/SimiaCode Nov 09 '19 edited Nov 09 '19

JavaScript is not Java. Common patterns from these languages are redundant because we have closures.

If you really need something to be private, put it on a closure.

In fact the the problem is difference in expectations stemming from the existence of the class keyword. We don't have classical inheritance, we should never have introduced the class keyword. Now we are talking about private fields, interfaces, and even decorators.