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: get-started/apA.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -109,7 +109,7 @@ In my opinion, if a function exists in your program, it has a purpose; otherwise
109
109
110
110
If a function has a name, you the code author should include that name in the code, so that the reader does not have to infer that name from reading and mentally executing that function's source code. Even a trivial function body like `x * 2` has to be read to infer a name like "double" or "multBy2"; that brief extra mental work is unnecessary when you could just take a second to name the function "double" or "multBy2" *once*, saving the reader that repeated mental work every time it's read in the future.
111
111
112
-
There are, regrettably in some respects, many other function definition forms in JS as of late 2019 (maybe more in the future!).
112
+
There are, regrettably in some respects, many other function definition forms in JS as of early 2020 (maybe more in the future!).
113
113
114
114
Here are some more declaration forms:
115
115
@@ -255,7 +255,7 @@ You just can't get away from coercions in JS comparisons. Buckle down and learn
255
255
256
256
In Chapter 3, we introduced prototypes and showed how we can link objects through a prototype chain.
257
257
258
-
Another way of wiring up such prototype linkages served as the (honestly, ugly) predecessor to the elegance of the ES6 `class` system (see Chapter 2), and is referred to as prototypal classes.
258
+
Another way of wiring up such prototype linkages served as the (honestly, ugly) predecessor to the elegance of the ES6 `class` system (see Chapter 2, "Classes"), and is referred to as prototypal classes.
Copy file name to clipboardExpand all lines: get-started/ch1.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,7 @@ In these cases, often TC39 will backtrack and simply choose to conform the speci
95
95
96
96
But occasionally, TC39 will decide the specification should stick firm on some point even though it is unlikely that browser-based JS engines will ever conform.
97
97
98
-
The solution? Appendix B, "Additional ECMAScript Features for Web Browsers" (as of the time of writing, here's the ES2019 Appendix B: https://www.ecma-international.org/ecma-262/10.0/#sec-additional-ecmascript-features-for-web-browsers). The JS specification includes this appendix to detail out any known mismatches between the official JS specification and the reality of JS on the web. In other words, these are exceptions that are allowed *only* for web JS; other JS environments must stick to the letter of the law.
98
+
The solution? Appendix B, "Additional ECMAScript Features for Web Browsers".[^specApB] The JS specification includes this appendix to detail out any known mismatches between the official JS specification and the reality of JS on the web. In other words, these are exceptions that are allowed *only* for web JS; other JS environments must stick to the letter of the law.
99
99
100
100
Section B.1 and B.2 cover *additions* to JS (syntax and APIs) that web JS includes, again for historical reasons, but which TC39 does not plan to formally specify in the core of JS. Examples include `0`-prefixed octal literals, the global `escape(..)` / `unescape(..)` utilities, String "helpers" like `anchor(..)` and `blink()`, and the RegExp `compile(..)` method.
101
101
@@ -145,7 +145,7 @@ But I'll just hint at some examples of quirks that have been true at various poi
145
145
146
146
* How non-strict mode `this` default-binding works for function calls, and whether the "global object" used will contain expected global variables.
147
147
148
-
* How hoisting (see "Scope & Closures," Chapter 3) works across multiple line entries.
148
+
* How hoisting (see Book 2, *Scope & Closures*) works across multiple line entries.
149
149
150
150
* ...several others
151
151
@@ -247,7 +247,7 @@ The original snippet relied on `let` to create block-scoped `x` variables in bot
247
247
248
248
| NOTE: |
249
249
| :--- |
250
-
| The `let` keyword was added in ES6 (in 2015). The preceding example of transpiling would only need to apply if an application needed to run in a pre-ES6 supporting JS environment. The example here is just for simplicity of illustration. When ES6 was new, the need for such a transpilation was quite prevalent, but in 2019 it's much less common to need to support pre-ES6 environments. The "target" used for transpiliation is thus a sliding window that shifts upward only as decisions are made for a site/application to stop supporting some old browser/engine. |
250
+
| The `let` keyword was added in ES6 (in 2015). The preceding example of transpiling would only need to apply if an application needed to run in a pre-ES6 supporting JS environment. The example here is just for simplicity of illustration. When ES6 was new, the need for such a transpilation was quite prevalent, but in 2020 it's much less common to need to support pre-ES6 environments. The "target" used for transpiliation is thus a sliding window that shifts upward only as decisions are made for a site/application to stop supporting some old browser/engine. |
251
251
252
252
You may wonder: why go to the trouble of using a tool to convert from a newer syntax version to an older one? Couldn't we just write the two variables and skip using the `let` keyword? The reason is, it's strongly recommended that developers use the latest version of JS so that their code is clean and communicates its ideas most effectively.
253
253
@@ -474,3 +474,5 @@ JS is a multi-paradigm language, meaning the syntax and capabilities allow a dev
474
474
JS is a compiled language, meaning the tools (including the JS engine) process and verify a program (reporting any errors!) before it executes.
475
475
476
476
With our language now *defined*, let's start getting to know its ins and outs.
477
+
478
+
[^specApB]: ECMAScript 2019 Language Specification, Appendix B: Additional ECMAScript Features for Web Browsers, https://www.ecma-international.org/ecma-262/10.0/#sec-additional-ecmascript-features-for-web-browsers (latest as of time of this writing in January 2020)
Copy file name to clipboardExpand all lines: get-started/ch2.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -462,7 +462,7 @@ But beware, it's more complicated than you'll assume. For example, how might you
462
462
463
463
### Coercive Comparisons
464
464
465
-
As mentioned earlier, coercion means a value of one type being converted to its respective representation in another type (to whatever extent possible). As we'll discuss in Chapter 4, coercion is a core pillar of the JS language, not some optional feature that can reasonably be avoided.
465
+
Coercion means a value of one type being converted to its respective representation in another type (to whatever extent possible). As we'll discuss in Chapter 4, coercion is a core pillar of the JS language, not some optional feature that can reasonably be avoided.
466
466
467
467
But where coercion meets comparison operators (like equality), confusion and frustration unfortunately crop up more often than not.
468
468
@@ -750,7 +750,7 @@ The `class` form stores methods and data on an object instance, which must be ac
750
750
751
751
With `class`, the "API" of an instance is implicit in the class definition—also, all data and methods are public. With the module factory function, you explicitly create and return an object with any publicly exposed methods, and any data or other unreferenced methods remain private inside the factory function.
752
752
753
-
There are other variations to this factory function form that are quite common across JS, even in 2019; you may run across these forms in different JS programs: AMD (Asynchronous Module Definition), UMD (Universal Module Definition), and CommonJS (classic Node.js-style modules). The variations, however, are minor (yet not quite compatible). Still, all of these forms rely on the same basic principles.
753
+
There are other variations to this factory function form that are quite common across JS, even in 2020; you may run across these forms in different JS programs: AMD (Asynchronous Module Definition), UMD (Universal Module Definition), and CommonJS (classic Node.js-style modules). The variations, however, are minor (yet not quite compatible). Still, all of these forms rely on the same basic principles.
754
754
755
755
Consider also the usage (aka, "instantiation") of these module factory functions:
Copy file name to clipboardExpand all lines: get-started/ch3.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -261,7 +261,7 @@ Remember: this closure is not over the value (like `1` or `3`), but over the var
261
261
262
262
Closure is one of the most prevalent and important programming patterns in any language. But that's especially true of JS; it's hard to imagine doing anything useful without leveraging closure in one way or another.
263
263
264
-
If you're still feeling unclear or shaky about closure, the majority of "Scope & Closures" (Book 2 of this series) is focused on the topic.
264
+
If you're still feeling unclear or shaky about closure, the majority of Book 2, *Scope & Closures* is focused on the topic.
Copy file name to clipboardExpand all lines: get-started/ch4.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ The second pillar of the language is the prototypes system. We covered this topi
37
37
38
38
JS is one of very few languages where you have the option to create objects directly and explicitly, without first defining their structure in a class.
39
39
40
-
For many years, people implemented the class design pattern on top of prototypes—so-called "prototypal inheritance" (see Appendix A)—and then with the advent of ES6's `class` keyword, the language doubled-down on its inclination toward OO/class-style programming.
40
+
For many years, people implemented the class design pattern on top of prototypes—so-called "prototypal inheritance" (see Appendix A, "Prototypal 'Classes'")—and then with the advent of ES6's `class` keyword, the language doubled-down on its inclination toward OO/class-style programming.
41
41
42
42
But I think that focus has obscured the beauty and power of the prototype system: the ability for two objects to simply connect with each other and cooperate dynamically (during function/method execution) through sharing a `this` context.
43
43
@@ -119,7 +119,7 @@ My suggestion for most readers is to proceed through this series in this order:
119
119
120
120
That's the intended order to read this book series.
121
121
122
-
However, books 2, 3, and 4 can generally be read in any order, depending on which topic you feel most curious about and comfortable exploring first. But I don't recommend you skip any of these three books—not even *Types & Grammar*, as some of you will be tempted to do!—even if you think you already have that topic down.
122
+
However, Books 2, 3, and 4 can generally be read in any order, depending on which topic you feel most curious about and comfortable exploring first. But I don't recommend you skip any of these three books—not even *Types & Grammar*, as some of you will be tempted to do!—even if you think you already have that topic down.
123
123
124
124
Book 5 (*Sync & Async*) is crucial for deeply understanding JS, but if you start digging in and find it's too intimidating, this book can be deferred until you're more experienced with the language. The more JS you've written (and struggled with!), the more you'll come to appreciate this book. So don't be afraid to come back to it at a later time.
0 commit comments