-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.js
More file actions
40 lines (33 loc) · 956 Bytes
/
classes.js
File metadata and controls
40 lines (33 loc) · 956 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
40
// // //ES6
// // console.log("is js working")
// class user {
// constructor(username, email, password) {
// this.username = username;
// this.email = email;
// this.password = password;
// }
// encrytPassword() {
// return `${this.password}abc`;
// }
// changeUserName() {
// return `${this.username.toUpperCase()}`;
// }
// }
// const fc1 = new user("wcoder547", "malik@gmail.com", 234);
// console.log(fc1.changeUserName());
// console.log(fc1.encrytPassword());
//behind the scenes
function user(username, email, password) {
this.username = username;
this.email = email;
this.password = password;
}
user.prototype.encrytPassword = function () {
return `${this.password}abc`;
};
user.prototype.changeUserName = function () {
return `${this.username.toUpperCase()}`;
};
const fc2 = new user("waseemmalik547", "hafiz@gmail.com", 234);
console.log(fc2.encrytPassword());
console.log(fc2.changeUserName());