File tree Expand file tree Collapse file tree 2 files changed +61
-46
lines changed Expand file tree Collapse file tree 2 files changed +61
-46
lines changed Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change 9
9
</ head >
10
10
11
11
< body >
12
- < script >
13
- class Pizza {
14
12
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
13
</ body >
60
14
61
15
</ html >
You can’t perform that action at this time.
0 commit comments