-
Notifications
You must be signed in to change notification settings - Fork 0
/
day23.js
174 lines (105 loc) · 2.1 KB
/
day23.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const student={
name:"karan",
email:"[email protected]",
password:3495,
printmarks: function(){
console.log("inside the funcs",this.password)
}
};
console.log(student.name);
let fruit=["fruit1","fruit2","fruit3","fruit4"]
fruit.push("fruit5")
console.log(fruit);
const employee={
calctax(){
console.log("tax is reduced");
}
}
const karaarajun={
salary:50000
}
const karaarajun2={
salary:60000
}
const karaarajun3={
salary:50000
}
const karaarajun4={
salary:50000
}
const karaarajun5={
salary:50000
}
const newemployee={
calctax(){
console.log("20% tax dedication");
}
}
karaarajun.__proto__=employee
karaarajun2.__proto__=employee
karaarajun3.__proto__=employee
karaarajun4.__proto__=employee
karaarajun5.__proto__=employee
newemployee.__proto__=employee
console.log(karaarajun3);
//classes
class car{
constructor(){
console.log("this is a constructor");
}
color(){
console.log("blue");
}
start(){
console.log("stop");
}
stop(){
console.log("stop");
}
setbrand(brandname){
this.brandname=brandname;
console.log("heyy this brand name is ",this.brandname);
}
}
let obj1=new car();
obj1.setbrand("ferrari")
let obj2=new car();
//inheritance
class parent{
constructor(){
this.parentname=parentname;
}
hello(){
console.log("hello");
}
}
class child extends parent{
constructor(){
console.log("child");
}
}
let obj4=new child();
console.log(obj4);
let DATA="old data";
class user{
constructor (name,email){
this.name=name;
this.email=email
}
viewdata(){
console.log("some data",DATA)
}
}
let student1=new ("karan","[email protected]")
let student2=new ("arjun","[email protected]")
student1.viewdata()
class admin extends user{
constructor (name,email){
super(name,email)
}
editdata(){
DATA="NEW DATA"
}
}
let adminuser=new admin("admin","[email protected]")
adminuser.editdata()