You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 20-Drawing-Animations/README.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@
6
6
7
7
#### Determining the value of this inside of an arrow function
8
8
9
+
Did you define the function with an arrow function?
10
+
R// Write 'console.log(this)' on the first **valid** line above the arrow function. Value of 'this' in the arrow function will be equal to that console log
11
+
9
12
```javascript
10
13
constcolors= {
11
14
printColor() {
@@ -32,4 +35,34 @@ colors.print()
32
35
33
36
#### Calling the function with bind, call or apply
34
37
35
-
**bind, call and apply** are built-in functions that belong to all functions inside of JavaScript that we create
38
+
Did you call 'bind', 'call' or 'apply' on the function when you invoked it?
39
+
R// 'this' is equal to the first argument of 'bind', 'call' or 'apply
40
+
41
+
**bind, call and apply** are built-in functions that belong to all functions inside of JavaScript that we create
42
+
43
+
```javascript
44
+
constprintThis=function() {
45
+
console.log(this)
46
+
}
47
+
48
+
printThis.call({ color:'red'})
49
+
printThis.apply({ color:'red'})
50
+
```
51
+
52
+
#### All other cases
53
+
'this' is equal to whatever is to the left of the '.' in the method call
0 commit comments