-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalss.html
More file actions
77 lines (71 loc) · 1.83 KB
/
calss.html
File metadata and controls
77 lines (71 loc) · 1.83 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Class in JavaScript</title>
</head>
<body>
<script>
class user {
constructor(username , email , password) {
this.username = username;
this.email = email;
this.password = password
}
encyptPassword(){
return `${this.password}abc`
}
changeUserName(){
return `${this.username.toUpperCase()}`
}
}
const chai =new user("chai"," chai@gamail" , "123")
console.log(chai.encyptPassword());
console.log(chai.changeUserName());
behind the seen
function user (username , email , password){
this.username = username;
this.email = email;
this.password = password
}
user.prototype.encyptPassword = function (){
return `${this.password}abc`
}
user.prototype.changeUserName = function (){
return `${this.username.toUpperCase()}`
}
const tea =new user("tea"," tea@gamail" , "123")
console.log(tea.encyptPassword());
console.log(tea.changeUserName());
// ************** inhertence ************
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(`new course adedd by ${this.username}`);
}
}
const chai = new teacher('chai' , "chai@yahoo" , "321")
// chai.addCourse();
chai.logMe();
const masalaChai = new User ('masalaChai')
masalaChai.logMe();
console.log(chai === masalaChai);
console.log(chai === teacher);
console.log(chai instanceof teacher);
console.log(chai instanceof User);
</script>
</body>
</html>