Skip to content

Commit e862050

Browse files
committed
create starter and finished files for classes video
1 parent 42b2851 commit e862050

File tree

2 files changed

+61
-46
lines changed

2 files changed

+61
-46
lines changed

playground/classes-FINISHED.html

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title>Classes</title>
8+
<link rel="stylesheet" href="../base.css">
9+
</head>
10+
11+
<body>
12+
<script>
13+
class Pizza {
14+
15+
// constructor
16+
constructor(toppings = [], customer) {
17+
// computer instance property
18+
this.toppings = toppings;
19+
this.customer = customer;
20+
}
21+
22+
// static property
23+
static toppings = ['pepperoni', 'cheese'];
24+
25+
// static method
26+
static randomPizza() {
27+
return new Pizza()
28+
}
29+
30+
// prototype method (almost always this)
31+
eat() {
32+
console.log('CHOMP');
33+
console.log(this.toppings);
34+
console.log(this.slices);
35+
}
36+
37+
// instance property
38+
slices = 10;
39+
40+
// instance method
41+
hi = () => {
42+
console.log('Hiiii');
43+
console.log(this);
44+
}
45+
46+
// Getter Property
47+
get length() {
48+
return this.slices;
49+
}
50+
51+
// Private Fields can only be modified inside a class
52+
#bankBalance = 10000;
53+
}
54+
55+
const myPizza = new Pizza(['onions'], 'Wes Bos');
56+
57+
console.log(myPizza);
58+
</script>
59+
</body>
60+
61+
</html>

playground/classes.html

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,7 @@
99
</head>
1010

1111
<body>
12-
<script>
13-
class Pizza {
1412

15-
// constructor
16-
constructor(toppings = [], customer) {
17-
// computer instance property
18-
this.toppings = toppings;
19-
this.customer = customer;
20-
}
21-
22-
// static property
23-
static toppings = ['pepperoni', 'cheese'];
24-
25-
// static method
26-
static randomPizza() {
27-
return new Pizza()
28-
}
29-
30-
// prototype method (almost always this)
31-
eat() {
32-
console.log('CHOMP');
33-
console.log(this.toppings);
34-
console.log(this.slices);
35-
}
36-
37-
// instance property
38-
slices = 10;
39-
40-
// instance method
41-
hi = () => {
42-
console.log('Hiiii');
43-
console.log(this);
44-
}
45-
46-
// Getter Property
47-
get length() {
48-
return this.slices;
49-
}
50-
51-
// Private Fields can only be modified inside a class
52-
#bankBalance = 10000;
53-
}
54-
55-
const myPizza = new Pizza(['onions'], 'Wes Bos');
56-
57-
console.log(myPizza);
58-
</script>
5913
</body>
6014

6115
</html>

0 commit comments

Comments
 (0)