-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclasses.js
35 lines (32 loc) · 940 Bytes
/
classes.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
//ES6
// class User{
// constructor(username,email,password){
// this.username = username;
// this.email = email;
// this.password = password
// }
// encryptPassword(){
// return `${this.password}abc`
// }
// changeUserName(){
// return `${this.username.toUpperCase()}`
// }
// }
// const chai = new User("gauri","[email protected]","123")
// console.log(chai.encryptPassword());
// console.log(chai.changeUserName());
//behind the scene
function User(username,email,password){
this.username = username;
this.email = email;
this.password = password
}
User.prototype.encryptPassword = function(){
return`${this.password}abc`
}
User.prototype.changeUserName = function(){
return`${this.password}abc`
}
const tea = new User("tea","njhgyddn.com","123")
console.log(tea.encryptPassword());
console.log(tea.changeUserName());