-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass2.html
40 lines (39 loc) · 1.08 KB
/
class2.html
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
38
39
40
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p id="demo"></p>
<p id="demo1"></p>
<p id="demo2"></p>
<script>
class student{
constructor(name,age){
this.studentname=name;
this.age=age;
}
showname()
{
return "STUDENT NAME IS "+this.studentname;
}
}
class subject extends student{
constructor(name,sub){
super(name);
this.subject=sub;
}
showdetail()
{
return this.showname()+" HE/SHE TAKES "+this.subject;
}
}
let student1=new subject("SHANU","SCIENCE");
let stu2=new student("SHAYOO","14");
document.getElementById("demo").innerHTML=student1.showdetail();
document.getElementById("demo1").innerHTML=stu2.showname();
//document.getElementById("demo2").innerHTML=stu2.showdelail();
</script>
</body>
</html>