What are your thoughts on using getters & setters in Javascript as opposed to methods? And when and why would you use them?
This
const obj1 = {
_name: 'Rick',
get name(){
return this._name;
},
set name(name){
this.name = name;
}
};
As opposed to
const obj2 = {
_name: 'Morty',
getName() {
return this._name;
},
setName(name){
this.name = name;
}
};