Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person {
- constructor(name, age) {
- this._name = name;
- this._age = age;
- }
- get tellMyName() {
- console.log(`I am ${this._name}`)
- }
- get tellMyAge() {
- console.log(`I am ${this._age}`)
- }
- }
- const pers1= new Person('John', '40');
- const pers2= new Person('Mary', '35');
- pers1.tellMyName;
- pers1.tellMyAge;
- pers2.tellMyName;
- pers2.tellMyAge;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement