-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay43Methodoverriding.html
47 lines (42 loc) · 1.53 KB
/
Day43Methodoverriding.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
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Day 43</title>
</head>
<body>
<script>
class Iphone{
constructor(size,camera,color){
this.size=size;
this.camera=camera;
this.color=color;
}
getphonedetails(model,rel){
console.log('parent')
return `Iphone${model} has ${this.size} size ,${this.camera} camera and ${this.color} ${rel}`
}
getphonecolour(){
return `${this.color}`
}
}
const phone6=new Iphone('6','12mp','gold');
//console.log(phone6.getphonedetails('6'));
class Newiphone extends Iphone{
constructor(size,camera,color,facereg){
super(size,camera,color);//calling the parent construtor (must use)
this.facereg=facereg;
}
getphonedetails(model){
console.log('child')
//console.log( super.getphonedetails(model));// calling parent method using super
return `Iphone${model} has ${this.size} size ,${this.camera} camera and ${this.color} facereg ${this.facereg}`
}
}
const phone11=new Newiphone('7','20mp','lightblue','true');
console.log(phone11.getphonedetails('11','2010'));
//console.log(phone11.getphonecolour());// called method from parent
</script>
</body>
</html>