What are getter and setter methods in ES6 class definition? Are they a prototype prototype? for reference:
class Person{ constructor(){}; get name(){ return 'jack'; } set name(){
this corresponds to Person.prototype.name = 'jack';
and another question, I saw examples of setters that use a prop instance, for example:
class Person{ constructor(){ this._name = 'jack'; }; get name(){ return this._name; } set name(val){ this._name = val; } }
I do not want to do this, I need something like:
class Person{ constructor(){}; get name(){ return 'jack'; } set name(val){
what can be done?
source share