class Person {
constructor(name) {
this.name = name;
}
speak() {
console.log('Hello this is ' + this.name);
}
}
class Child extends Person {
// private property
#age; // 1we can access to age property only in this class
constructor(name, age) {
super(name);
this.#age = age; //2
}
}
// we got an error again !
class GrandChild extends Child {
getAge() {
console.log(this.#age);
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.