Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
githubAmanKumar authored Mar 23, 2024
1 parent 2b026a9 commit 3739d94
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions 10_Classes_and_OOP/myClasses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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("chai", "chai@gmail.com", "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.username.toUpperCase()}`
}


const tea = new User("tea", "tea@gmail.com", "123")

console.log(tea.encryptPassword());
console.log(tea.changeUsername());

0 comments on commit 3739d94

Please sign in to comment.