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: day_07.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,14 +18,14 @@
18
18
19
19
## `this` Keyword
20
20
21
-
Over and over again I see engineers struggling with `this` topic; is so weird!! Long ago I found myself in the same situation, like, being writing code for many years and still ... never took the time to really understand `this` when `this` is one of the most important and powerful features in JavaScript!
22
-
Engineers we feel so frustrated about `this` that there's even a joke for `this`!
21
+
Over and over again I see engineers struggling with `this` topic; it's so weird!! Long ago I found myself in the same situation, like, writing code for many years and still ... never took the time to really understand `this` when `this` is one of the most important and powerful features in JavaScript!
22
+
As engineers, we feel so frustrated about `this` that there's even a joke for `this`!
23
23
24
24
> JavaScript makes me want to flip the table and say "F*** this shit", but I can never be sure what **`this`** refers to.
25
25
26
-
The good things came when I took the responsibility of `this` and accepted the guilt was entirely mine.
26
+
Things got better when I took the responsibility of `this` and accepted that the blame was entirely mine.
27
27
28
-
Why this intro? because there are tons of articles regarding `this` but everything about `this` was written by **Kyle Simpson** who dedicated a whole book for `this` topic , so we're gonna read and study it until we breath`this`.
28
+
Why this intro? because there are tons of articles regarding `this` but everything about `this` was written by **Kyle Simpson** who dedicated a whole book for `this` topic , so we're gonna read and study it until we breathe`this`.
29
29
30
30
### Resolving `this`
31
31
@@ -53,7 +53,7 @@ Now we've learned that `this` has specific rules and it's resolved at run-time,
Now, there's a catch!!! it seems that depending on a thing called **mode**, that depending on it's[strictness](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) or [non-strictness](https://developer.mozilla.org/en-US/docs/Glossary/Sloppy_mode) (a.k.a. Sloppy) it'll alter the semantics and behavior of many things including `this`.
56
+
Now, there's a catch!!! it seems that depending on a thing called **mode**, that depending on its[strictness](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) or [non-strictness](https://developer.mozilla.org/en-US/docs/Glossary/Sloppy_mode) (a.k.a. Sloppy) will alter the semantics and behavior of many things including `this`.
57
57
58
58
---
59
59
@@ -71,8 +71,8 @@ Now, there's a catch!!! it seems that depending on a thing called **mode**, that
71
71
#### TL;DR
72
72
73
73
1. Eliminates some JavaScript `silent errors` by changing them `to throw errors`.
74
-
2. Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode.
75
-
3. Prohibits some syntax likely to be defined in future versions of ECMAScript.
74
+
2. Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not in strict mode.
75
+
3. Prohibits some syntax likely from be defined in future versions of ECMAScript.
76
76
77
77
### Semantic differences
78
78
@@ -100,7 +100,7 @@ When adding `'use strict';` the following cases will throw an Error:
100
100
- Escape characters are not allowed `var y = \010;`
101
101
- Declaring function in blocks `if (a < b) { function f() {} }`
102
102
- Obvious errors
103
-
- Declaring twice the same name for a property name in an object literal `{a: 1, b: 3, a: 7}` This is no longer the case in ECMAScript 2015 (bug 1041128).
103
+
- Declaring the same name twice for a property name in an object literal `{a: 1, b: 3, a: 7}` This is no longer the case in ECMAScript 2015 (bug 1041128).
104
104
- Declaring two function parameters with the same name function `f(a, b, b) {}`
105
105
- TypeError
106
106
- Writing to a get-only property is not allowed
@@ -150,7 +150,7 @@ f(); // 6
150
150
151
151
```
152
152
153
-
One of the most expected and misused features of ES6 is the Arrow Function. Undoubtedly powerful it might also derive in a headache if you don't really know how they work and which are the differences between the full body notation and the arrow notation.
153
+
One of the most expected and misused features of ES6 is the Arrow Function. Undoubtedly powerful, it might also derive in a headache if you don't really know how they work and what the differences are between the full body notation and the arrow notation.
154
154
155
155
Let's take a look at [YDKJS - ES6 & Beyond - chapter 2](https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/es6%20%26%20beyond/ch2.md#arrow-functions)
156
156
@@ -159,7 +159,7 @@ Let's take a look at [YDKJS - ES6 & Beyond - chapter 2](https://github.com/getif
159
159
## Generators
160
160
161
161
So far we've seen (except for the iterators) only **[run-to-completion](https://en.wikipedia.org/wiki/Run_to_completion_scheduling)** examples of code. It means, "the execution won't stop until it's done or fails".
162
-
What if I tell you there's a feature that let you define a function capable of being paused midway and resumed later?
162
+
What if I tell you there's a feature that lets you define a function capable of being paused midway and resumed later?
163
163
164
164
Together with [`iterators`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) ES6 introduced something called `generators`.
0 commit comments