@@ -41,28 +41,67 @@ R// 'this' is equal to the first argument of 'bind', 'call' or 'apply
4141** bind, call and apply** are built-in functions that belong to all functions inside of JavaScript that we create
4242
4343``` javascript
44- const printThis = function () {
44+ const printThis = function () {
4545 console .log (this )
4646}
4747
48- printThis .call ({ color: ' red' })
49- printThis .apply ({ color: ' red' })
48+ printThis .call ({ color: ' red' })
49+ printThis .apply ({ color: ' red' })
5050```
5151
5252#### All other cases
53+
5354'this' is equal to whatever is to the left of the '.' in the method call
5455
5556``` javascript
5657const colors = {
5758 printColor () {
5859 console .log (this )
59- }
60+ },
6061}
6162
6263const randomObject = {
63- a: 1
64+ a: 1 ,
6465}
6566
6667randomObject .printColor = colors .printColor
6768randomObject .printColor ()
68- ```
69+ ```
70+
71+ ## 3. 10 Starting and Pausing the Timer
72+
73+ ``` javascript
74+ class Timer {
75+ constructor (durationInput , startButton , pauseButton ) {
76+ this .durationInput = durationInput
77+ this .startButton = startButton
78+ this .pauseButton = pauseButton
79+
80+ // start(){}, Calling the constructor anytime the user clicks on the start button
81+ this .startButton .addEventListener (' click' , this .start )
82+ this .pauseButton .addEventListener (' click' , this .pause )
83+ }
84+
85+ // start() {
86+ // // console.log('Time to start the timer!');
87+ // console.log(this);
88+ // }
89+ start = () => {
90+ // This runs on tick immediately
91+ this .tick ()
92+ // const timer = setInterval(this.tick, 1000)
93+ this .interval = setInterval (this .tick , 1000 )
94+ console .log (timer)
95+ // function that is built into the browser
96+ // clearInterval(timer)
97+ }
98+
99+ pause = () => {
100+ clearInterval (this .interval )
101+ }
102+
103+ tick = () => {
104+ console .log (' tick' )
105+ }
106+ }
107+ ```
0 commit comments