DEV Community

Discussion on: ECMAScript 2021 New Updates

Collapse
 
animeshmaru profile image
Animesh

Yes, we can have public getter function to get a private properties.

Collapse
 
baenencalin profile image
Calin Baenen

I'm specifically referring to them sharing the same name, so the getter can let you do .priv without just giving you (direct) access to .priv.

Thread Thread
 
animeshmaru profile image
Animesh • Edited

Ok, your example is correct. In new update now we can make getter function also private so that it can only be accessed inside the class, but priv in your ex can be get from outside.