-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.js
More file actions
37 lines (36 loc) · 735 Bytes
/
Copy pathclass.js
File metadata and controls
37 lines (36 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class a{
constructor(num,str){
this.num=num;
this.str=str;
}
static hello(){
return 'hello'
}
static printHello(){
let text=this.hello();
console.log(text)
}
set add(value){
this.value=value;
document.querySelector('').innerHTML=this.value;
}
get add(){
return `${this.num},${this.str},${this.value}`
}
}
class b extends a{
constructor(syb){
super(num,str)
this.syb=syb;
}
get add(){
return `${this.num},${this.str},${this.value},${this.syb}`
}
}
a.printHello(); //hello
const a1=new a(1,2);
a1.add=4;
console.log(a1.add)//1,2,4
const b1=new b(1,2,3);
b1.add=4;
console.log(b1.add)//1,2,4,3