-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.js
More file actions
39 lines (28 loc) · 946 Bytes
/
inheritance.js
File metadata and controls
39 lines (28 loc) · 946 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
38
39
class User {
constructor(username){
this.username = username
}
logMe(){
console.log(`USERNAME is ${this.username}`)
}
}
class Teacher extends User{
constructor(username, email, password){
super(username)
this.email = email;
this.password = password;
}
addCourse(){
console.log(`A new course was added by ${this.username}`);
}
}
const chai = new Teacher("cahi", "cahi@google.com","123")
// chai.logMe();
const masalaChai = new User("chai garam")
// masalaChai.addCourse();
// masalaChai.logMe()
// console.log(chai === masalaChai) (false)
// console.log(chai === Teacher); (false)
// console.log(chai === User); (false)
// console.log(chai instanceof Teacher); (true)
console.log(chai instanceof User); // (true)