-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path06-object-prototype.html
48 lines (39 loc) · 1.21 KB
/
06-object-prototype.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Object - Prototype</title>
</head>
<body>
<script>
function Person(firstName, middleName, lastName){
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
this.sayHello = function(name) {
console.info(`Hello ${name}, my name is ${this.firstName}`);
}
}
Person.prototype.sayBye = function () {
console.info("Good Bye");
}
Person.prototype.run = function () {
console.info(`${this.firstName} is running`);
}
const faqih = new Person("Faqih", "Pratama", "Muhti");
faqih.sayBye = function() {
console.info("Good Bye");
};
faqih.sayBye = function(){
console.info("Sampai Jumpa");
}
const fitrya = new Person("Fityra", "", "Muhti");
console.info(faqih);
console.info(fitrya);
faqih.sayBye();
faqih.run();
</script>
</body>
</html>