Now is the best moment to implement protected fields in classes

The ECMAScript 2022 brought support to private fields in classes using # but still without support to protected fields (still acessible internaly in subclasses but not externaly). This resource can be very useful and already is implemented (declaration only) in typescript.

1 Like

That's because, as has been discussed extensively on other threads, "protected" doesn't make any sense in JS. JS doesn't have "access levels", it has "reachability" - things are either reachable or aren't.

I'd recommend searching this discourse for other discussions on the subject.


One of those thread where it is postulated that there may be a way to implement protected like semantics: A simple way to implement protected