| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- (function () {
- class Person {
- constructor(name1, age1) {
- this.name1 = name1;
- this.age1 = age1;
- }
- /**
- * get 获取
- * set 设置
- */
- get aa() {
- return this.name1;
- }
- set bb(val) {
- this.name1 = val;
- }
- }
- let p = new Person('孙悟空', 20);
- console.log(p);
- // Person.name1 = '你好'
- // p.name1 = 'haha';
- console.log(p, '111');
- // p.aa()
- console.log(p.aa);
- p.bb = '大家好';
- console.log(p);
- // p.getName();
- // console.log(Person)
- class A {
- constructor(num) {
- this.num = num;
- }
- get num1() {
- return this.num;
- }
- set num1(val) {
- this.num = val;
- }
- }
- class B extends A {
- say() {
- console.log(this.num);
- }
- }
- let b = new B(10);
- b.say();
- // b.num= 20;
- console.log(b);
- b.num1 = 20;
- console.log(b);
- })();
|