Peter Seliger
Mar 10, 2024

The author should consider either removing or entirely reworking this article. Why? First, property getters and setters already are a feature of ES5, thus the author's 2nd example code, a constructor function with the locally enclosed (closure) marks variable in combination with a get property method (like shown in the author's 1st, class based example) does actually work. Second, the 1st, class based example code makes use of the pseudo private underscore based annotation which is just an annotation developers once choose to agree about, thus this coding style does still exposes every such annotated property into public. True private fields (properties and methods) are achieved by the hash / # syntax, which implements/assures true privacy. In combination with get/set one can steer precisely how one wants to implement controlled access to such private fields.

At the author, please do your homework first before trying to advocate people.

No responses yet