Preface |
|
xiii | |
Acknowledgments |
|
xv | |
About this book |
|
xvii | |
About the author |
|
xxi | |
About the cover illustration |
|
xxii | |
|
|
1 | (20) |
|
|
4 | (1) |
|
|
5 | (2) |
|
|
7 | (5) |
|
|
12 | (1) |
|
|
13 | (3) |
|
1.6 Sample application: Blockchain |
|
|
16 | (5) |
|
|
21 | (50) |
|
2 Inheritance-based object modeling |
|
|
23 | (19) |
|
2.1 Reviewing prototypal inheritance |
|
|
24 | (6) |
|
Property resolution process |
|
|
27 | (2) |
|
|
29 | (1) |
|
2.2 Constructor functions |
|
|
30 | (6) |
|
|
30 | (1) |
|
Sharing properties by using constructors and prototypes |
|
|
31 | (5) |
|
2.3 Class-based inheritance |
|
|
36 | (6) |
|
3 Linked, compositional object models |
|
|
42 | (29) |
|
3.1 Types of object links |
|
|
43 | (2) |
|
|
43 | (1) |
|
|
44 | (1) |
|
|
45 | (5) |
|
3.3 Understanding Object assign |
|
|
50 | (4) |
|
|
51 | (2) |
|
|
53 | (1) |
|
3.4 Assembling objects using mixin composition |
|
|
54 | (12) |
|
|
60 | (3) |
|
Multiple inheritance and linearization |
|
|
63 | (2) |
|
Composing objects using Object.assign and the spread operator |
|
|
65 | (1) |
|
3.5 Applying shared mixins to multiple objects |
|
|
66 | (5) |
|
|
71 | (84) |
|
4 Writing composable, pure code |
|
|
73 | (41) |
|
4.1 What is functional programming? |
|
|
75 | (4) |
|
|
76 | (2) |
|
|
78 | (1) |
|
4.2 Functional versus imperative at a glance |
|
|
79 | (2) |
|
4.3 Composition: The functional way |
|
|
81 | (9) |
|
Working with side effects |
|
|
84 | (3) |
|
|
87 | (3) |
|
4.4 Currying and closures |
|
|
90 | (10) |
|
Curried function application |
|
|
91 | (5) |
|
The curry and composition dynamic duo |
|
|
96 | (4) |
|
4.5 Working with immutable objects |
|
|
100 | (4) |
|
|
104 | (2) |
|
4.7 Imperative to functional transformation |
|
|
106 | (5) |
|
4.8 Native function chains |
|
|
111 | (3) |
|
4 Higher-kinded composition |
|
|
114 | (41) |
|
5.1 Closing over data types |
|
|
117 | (5) |
|
5.2 New Array APIs: {flat, flatMap} |
|
|
122 | (1) |
|
|
122 | (1) |
|
|
122 | (1) |
|
5.3 The map/compose correspondence |
|
|
123 | (1) |
|
|
124 | (7) |
|
|
124 | (3) |
|
|
127 | (4) |
|
5.5 Contextual validation with higher-order functions |
|
|
131 | (19) |
|
|
131 | (1) |
|
|
132 | (2) |
|
Modeling success and failure with the Validation monad |
|
|
134 | (4) |
|
|
138 | (4) |
|
Higher-kinded composition with Validation |
|
|
142 | (2) |
|
Point-free coding with monads |
|
|
144 | (2) |
|
Reducing complex data structures |
|
|
146 | (3) |
|
|
149 | (1) |
|
5.6 Higher-kinded composition with method extraction and dynamic binding |
|
|
150 | (5) |
|
|
155 | (68) |
|
|
157 | (26) |
|
6.1 Past state of affairs |
|
|
158 | (2) |
|
|
160 | (7) |
|
|
161 | (2) |
|
Immediately Invoked Function Expressions (IIFEs) |
|
|
163 | (1) |
|
|
164 | (1) |
|
|
165 | (2) |
|
6.3 Static vs. dynamic module systems |
|
|
167 | (3) |
|
|
170 | (8) |
|
|
171 | (1) |
|
|
172 | (2) |
|
|
174 | (3) |
|
|
177 | (1) |
|
6.5 Benefits of ESM for tooling |
|
|
178 | (5) |
|
Dead-code elimination and tree-shaking |
|
|
178 | (2) |
|
|
180 | (1) |
|
|
181 | (2) |
|
7 Hooked on metaprogramming |
|
|
183 | (40) |
|
7.1 Common uses of metaprogramming in JavaScript |
|
|
184 | (2) |
|
|
186 | (2) |
|
|
188 | (2) |
|
|
188 | (1) |
|
|
189 | (1) |
|
7.4 Practical application of symbols |
|
|
190 | (8) |
|
|
190 | (1) |
|
|
191 | (5) |
|
|
196 | (2) |
|
|
198 | (13) |
|
|
198 | (1) |
|
|
199 | (1) |
|
|
200 | (3) |
|
|
203 | (2) |
|
|
205 | (6) |
|
7.6 Dynamic introspection and weaving |
|
|
211 | (7) |
|
|
212 | (3) |
|
|
215 | (1) |
|
|
216 | (2) |
|
7.7 Implementing method decorators |
|
|
218 | (5) |
|
|
223 | (83) |
|
|
225 | (35) |
|
8.1 Architecture at a glance |
|
|
226 | (2) |
|
8.2 JavaScript as promised |
|
|
228 | (16) |
|
Principle of data locality |
|
|
231 | (1) |
|
|
231 | (3) |
|
|
234 | (8) |
|
|
242 | (2) |
|
8.3 API review: Promise combinators |
|
|
244 | (5) |
|
|
246 | (1) |
|
|
247 | (1) |
|
|
247 | (1) |
|
|
248 | (1) |
|
|
249 | (3) |
|
|
252 | (5) |
|
|
257 | (3) |
|
|
260 | (46) |
|
9.1 Iterables and Iterators |
|
|
262 | (4) |
|
|
262 | (1) |
|
|
263 | (1) |
|
|
263 | (3) |
|
|
266 | (7) |
|
|
266 | (1) |
|
Creating iterable objects |
|
|
267 | (2) |
|
|
269 | (4) |
|
9.3 Working with data streams |
|
|
273 | (5) |
|
|
274 | (1) |
|
Implementing a streamable array |
|
|
275 | (3) |
|
9.4 Welcoming a new native: Observable |
|
|
278 | (26) |
|
|
279 | (2) |
|
Creating custom observables |
|
|
281 | (1) |
|
Building your own reactive toolkit |
|
|
282 | (6) |
|
Observable mixin extension |
|
|
288 | (2) |
|
Representing push streams with generators |
|
|
290 | (5) |
|
|
295 | (2) |
|
|
297 | (3) |
|
|
300 | (4) |
|
|
304 | (2) |
Appendix A Configuring Babel |
|
306 | (2) |
Appendix B Typed JavaScript<T> |
|
308 | (17) |
Index |
|
325 | |