-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise5.html
More file actions
44 lines (42 loc) · 1.27 KB
/
exercise5.html
File metadata and controls
44 lines (42 loc) · 1.27 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Exercise #5</title>
<script type="text/javascript">
let unitCircle = {
x: 0,
y: 0,
radius: 1,
area: function(){ return Math.PI * this.radius * this.radius;}
};
unitCircle.color = "red";
unitCircle.thickness = 3;
console.log(unitCircle);
delete unitCircle.color;
// unitCircle has no color!
console.log(unitCircle);
console.log(`Area is ${unitCircle.area()}`);
for (let property in unitCircle){ // reflection
console.log(`${property}: ${unitCircle[property]}`);
}
const x = 10;
const y = 100;
const radius = 20;
// const circle = {x: x,y: y,radius: radius};
const circle = {x,y,radius};
console.log(circle);
const jack = {identity: "1" , salary: 100_000, iban: "tr1"};
let anotherJack = {...jack};
jack.salary += 10_000;
anotherJack.salary += 30_000;
console.log(jack);
console.log(anotherJack);
let {salary,iban} = {...jack};
console.log(salary);
console.log(iban);
</script>
</head>
<body>
</body>
</html>