classSubject{constructor(){this.name =null;this.__id =null;}say(){thrownewError("Abstract method cannot be called");}}classRealSubjectextendsSubject{constructor(){super();this.name ="real subject";this.__id =1;}say(){ console.log(this.name);}}classSubjectProxy{constructor(){this.instance =newRealSubject;}say(){this.instance.say();}getProperty(key){if(/^_{1,2}.*$/.test(key))thrownewError("Properties beginning with _ or __ are not allowed to be accessed");returnthis.instance[key];}}(function(){var subject =newSubjectProxy(); subject.say();// real subject console.log(subject.getProperty("name"));// real subject// console.log(subject.getProperty("__id")); // Uncaught Error: Properties beginning with _ or __ are not allowed to be accessed})();