| 123456789101112131415161718192021222324252627282930313233 |
- "use strict";
- (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);
- })();
|