Hello!
I have a question about the example.
- Why are there “author” and “_author”?
What is underline for? - I am using CodePen to check the code.
But it doesn’t overwrite the properties of lol.writer with this code -> lol.writer = ‘wut’;
Is it because I am using CodePen or wrong code?
Thank you your help in advance!!
class Book {
constructor(author) {
this._author = author;
}
// getter
get writer(){
return this._author;
}
// setter
set writer(updatedAuthor){
this._author = updatedAuthor;
}
}
const lol = new Book('anonymous');
console.log(lol.writer); // anonymous
**lol.writer = 'wut';**
**console.log(lol.writer); // wut**