-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise7.html
More file actions
34 lines (31 loc) · 973 Bytes
/
exercise7.html
File metadata and controls
34 lines (31 loc) · 973 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OOP in JS</title>
<script type="text/javascript">
class Employee {
constructor(identity, fullname, salary, iban) {
this.identity = identity;
this.fullname = fullname;
this.salary = salary;
this.iban = iban;
// this.sayHello = this.sayHello.bind(this);
}
sayHello = () => {
console.log(this);
console.log(`Hello, ${this.fullname}!`);
}
}
const jack = new Employee("1", "jack bauer", 100_000, "tr1");
const kate = new Employee("2", "kate austen", 200_000, "tr2");
jack.sayHello(); // sayHello(jack);
kate.sayHello(); // sayHello(kate);
console.log(jack)
console.log(kate)
window.setInterval(jack.sayHello, 3_000);
</script>
</head>
<body>
</body>
</html>