| 1 | class User { |
| 2 | |
| 3 | constructor(name) { |
| 4 | // invokes the setter |
| 5 | this.name = name; |
| 6 | } |
| 7 | |
| 8 | get name() { |
| 9 | return this._name; |
| 10 | } |
| 11 | |
| 12 | set name(value) { |
| 13 | if (value.length < 4) { |
| 14 | console.log("Name is too short."); |
| 15 | return; |
| 16 | } |
| 17 | this._name = value; |
| 18 | } |
| 19 | |
| 20 | } |
| 21 | |
| 22 | let user = new User("John"); |
| 23 | console.log(user.name); // John |
nothing calls this directly
no outgoing calls
no test coverage detected