-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12d1e99
commit bc21502
Showing
5 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>React</title> | ||
</head> | ||
<body> | ||
<button>Button Clicked</button> | ||
</body> | ||
<script> | ||
class React { | ||
constructor(){ | ||
this.library = "React" | ||
this.server = "https://localhost:300" | ||
|
||
//requirement | ||
document | ||
.queryselector('button') | ||
.addEventListener('click', this.handleClick) | ||
|
||
} | ||
handleClick(){ | ||
console.log("Button clicked"); | ||
console.log(this); | ||
} | ||
} | ||
const app = new React | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
function SetUsername(username){ | ||
function setUsername(username){ | ||
//complex DB calls | ||
this.username = username | ||
console.log("called"); | ||
|
@@ -11,5 +11,5 @@ function createUser(username, email, password){ | |
this.password = password | ||
} | ||
|
||
const chai = new creatUser("coffee", "[email protected]", "12345") | ||
const chai = new createUser("coffee", "[email protected]", "12345") | ||
console.log(coffee); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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("justin", "[email protected]", "123") | ||
chai.addCourse() | ||
const masalaChai = new User("masalaChai") | ||
masalaChai.logMe() | ||
|
||
console.log(chai === Teacher); | ||
console.log(chai instanceof User); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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("justin", "[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("chai", "[email protected]", "123") | ||
console.log(tea.encryptPassword()); | ||
console.log(tea.changeUsername()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class User{ | ||
constructor(username){ | ||
this.username = username | ||
} | ||
logMe(){ | ||
console.log(`Username: ${this.username}`); | ||
} | ||
|
||
static createid(){ | ||
return `123` | ||
} | ||
} | ||
|
||
const justin = new User("Justin") | ||
// console.log(justin.createid()) | ||
|
||
class Teacher extends User{ | ||
constructor(username, email){ | ||
super(username) | ||
this.email = email | ||
} | ||
} | ||
|
||
const iphone = new Teacher("iphone", "[email protected]") | ||
console.log(iphone.createId()); |