Hi I have the following class definition:
'use strict'
class Human {
constructor(name, age) {
this._name = name || null;
this.age = age || 'no age defined';
this.rights = ['Human Rights'];
}
get this() {
return 'access denied';
}
set name(name) {
this._name = this._name ? this._name : name;
}
get name() {
return this._name;
}
}
let me = new Human();
console.log(me); // this should return a string "access denied"
I thought it might be possible to define a getter for the whole instance. But this is not, or? Does anyone know anything about that? Or is there an alternative methods to create restricted Classes?
kind regards martin