| 1234567891011121314151617181920212223242526272829303132 |
- (function () {
- class Person {
- constructor(name, age, color) {
- this.name = name;
- this.age = age;
- this.color = color;
- }
- get age1() {
- return this.age;
- }
- set age1(val) {
- this.age = val;
- }
- getValue() {
- return this.age + 10;
- }
- }
- class Child extends Person {
- look() {
- console.log(this.color);
- }
- }
- let p = new Person("孙悟空", 20, '红色');
- let c = new Child('图图', 2, '白色');
- p.age1 = 30;
- console.log(p.age1);
- // console.log(p.age);
- // console.log()
- c.look();
- console.log(p.getValue());
- // console.log(c.color);
- })();
|