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: debugging/code-reading/readme.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,8 @@ Take a look at the following code:
17
17
18
18
Explain why line 5 and line 8 output different numbers.
19
19
20
+
Due to x holding different values in global scope and functional scope
21
+
20
22
## Question 2
21
23
22
24
Take a look at the following code:
@@ -35,6 +37,9 @@ console.log(y);
35
37
36
38
What will be the output of this code. Explain your answer in 50 words or less.
37
39
40
+
The first console.log will log 10 to the console, while the second will log undefined and throw a reference error due to y only being available in the function
41
+
42
+
38
43
## Question 3
39
44
40
45
Take a look at the following code:
@@ -62,3 +67,6 @@ console.log(y);
62
67
```
63
68
64
69
What will be the output of this code. Explain your answer in 50 words or less.
70
+
71
+
First console.log outputs 9 as x is passed and the f1 call doesn't alter its value outside the fn.
72
+
Second console.log prints the object {x:10} as f2 increments y.x by 1
0 commit comments