0%

The Joy of JavaScript introduces techniques that turn JavaScript programmers into JavaScript pros. You’ll work with cutting edge APIs, language features, and coding styles to tackle tricky problems in an elegant manner. Along the way, you’ll practice good object design, drive business logic with functional thinking, and untangle complex data flows.

Table of Contents

  1. inside front cover
  2. The Joy of JavaScript
  3. Copyright
  4. dedication
  5. brief contents
  6. contents
  7. front matter
    1. preface
    2. acknowledgments
    3. about this book
    4. about the author
    5. about the cover illustration
  8. 1 JavaScript reloaded
    1. 1.1 Evolving JavaScript
    2. 1.2 Objects
    3. 1.3 Functions
    4. 1.4 Code
    5. 1.5 Data
    6. 1.6 Sample application: Blockchain
    7. Summary
  9. Part 1. Objects
  10. 2 Inheritance-based object modeling
    1. 2.1 Reviewing prototypal inheritance
    2. 2.1.1 Property resolution process
    3. 2.1.2 Differential inheritance
    4. 2.2 Constructor functions
    5. 2.2.1 Functions as templates
    6. 2.2.2 Sharing properties by using constructors and prototypes
    7. 2.3 Class-based inheritance
    8. Summary
  11. 3 Linked, compositional object models
    1. 3.1 Types of object links
    2. 3.1.1 Implicit
    3. 3.1.2 Explicit
    4. 3.2 OLOO
    5. 3.3 Understanding Object.assign
    6. 3.3.1 Object.assign uncovered
    7. 3.3.2 Assignment vs definition
    8. 3.4 Assembling objects using mixin composition
    9. 3.4.1 Anatomy of a mixin
    10. 3.4.2 Multiple inheritance and linearization
    11. 3.4.3 Composing objects using Object.assign and the spread operator
    12. 3.5 Applying shared mixins to multiple objects
    13. Summary
  12. Part 2. Functions
  13. 4 Writing composable, pure code
    1. 4.1 What is functional programming?
    2. 4.1.1 Functions as data
    3. 4.1.2 The functional way
    4. 4.2 Functional versus imperative at a glance
    5. 4.3 Composition: The functional way
    6. 4.3.1 Working with side effects
    7. 4.3.2 Decomposing complex code
    8. 4.4 Currying and closures
    9. 4.4.1 Curried function application
    10. 4.4.2 The curry and composition dynamic duo
    11. 4.5 Working with immutable objects
    12. 4.6 Point-free coding
    13. 4.7 Imperative to functional transformation
    14. 4.8 Native function chains
    15. Summary
  14. 5 Higher-kinded composition
    1. 5.1 Closing over data types
    2. 5.2 New Array APIs: {flat, flatMap}
    3. 5.2.1 Array.prototype.flat
    4. 5.2.2 Array.prototype.flatMap
    5. 5.3 The map/compose correspondence
    6. 5.4 Universal contracts
    7. 5.4.1 Functors
    8. 5.4.2 Monads
    9. 5.5 Contextual validation with higher-order functions
    10. 5.5.1 Kinds of ADTs
    11. 5.5.2 Choices
    12. 5.5.3 Modeling success and failure with the Validation monad
    13. 5.5.4 Composing with monads
    14. 5.5.5 Higher-kinded composition with Validation
    15. 5.5.6 Point-free coding with monads
    16. 5.5.7 Reducing complex data structures
    17. 5.5.8 Third-party integration
    18. 5.6 Higher-kinded composition with method extraction and dynamic binding
    19. Summary
  15. Part 3. Code
  16. 6 ECMAScript Modules
    1. 6.1 Past state of affairs
    2. 6.2 Module patterns
    3. 6.2.1 Object namespaces
    4. 6.2.2 Immediately Invoked Function Expressions (IIFEs)
    5. 6.2.3 IIFE mixins
    6. 6.2.4 Factory functions
    7. 6.3 Static vs. dynamic module systems
    8. 6.4 ESM basics
    9. 6.4.1 Path specifiers
    10. 6.4.2 Exporting
    11. 6.4.3 Importing
    12. 6.4.4 A new extension in town
    13. 6.5 Benefits of ESM for tooling
    14. 6.5.1 Dead-code elimination and tree-shaking
    15. 6.5.2 Faster property lookups
    16. 6.5.3 Type-friendliness
    17. Summary
  17. 7 Hooked on metaprogramming
    1. 7.1 Common uses of metaprogramming in JavaScript
    2. 7.2 JavaScript symbols
    3. 7.3 Symbol registries
    4. 7.3.1 Local registry
    5. 7.3.2 Global registry
    6. 7.4 Practical application of symbols
    7. 7.4.1 Hidden properties
    8. 7.4.2 Interoperability
    9. 7.4.3 Serialization
    10. 7.5 Well-known symbols
    11. 7.5.1 @@toStringTag
    12. 7.5.2 @@isConcatSpreadable
    13. 7.5.3 @@species
    14. 7.5.4 @@toPrimitive
    15. 7.5.5 @@iterator
    16. 7.6 Dynamic introspection and weaving
    17. 7.6.1 Proxy objects
    18. 7.6.2 The Reflect API
    19. 7.6.3 Additional use cases
    20. 7.7 Implementing method decorators
    21. Summary
  18. Part 4. Data
  19. 8 Linear async flows
    1. 8.1 Architecture at a glance
    2. 8.2 JavaScript as promised
    3. 8.2.1 Principle of data locality
    4. 8.2.2 Are promises algebraic?
    5. 8.2.3 Fluent chaining
    6. 8.2.4 Promises in the wild
    7. 8.3 API review: Promise combinators
    8. 8.3.1 Promise.all
    9. 8.3.2 Promise.race
    10. 8.3.3 Promise.allSettled
    11. 8.3.4 Promise.any
    12. 8.4 async made easy
    13. 8.5 async iteration
    14. 8.6 Top-level await
    15. Summary
  20. 9 Streams programming
    1. 9.1 Iterables and Iterators
    2. 9.1.1 Iterable protocol
    3. 9.1.2 Iterator protocol
    4. 9.1.3 Examples
    5. 9.2 Generators
    6. 9.2.1 To return or to yield
    7. 9.2.2 Creating iterable objects
    8. 9.2.3 Async generators
    9. 9.3 Working with data streams
    10. 9.3.1 What is a stream?
    11. 9.3.2 Implementing a streamable array
    12. 9.4 Welcoming a new native: Observable
    13. 9.4.1 What is an Observable?
    14. 9.4.2 Creating custom observables
    15. 9.4.3 Building your own reactive toolkit
    16. 9.4.4 Observable mixin extension
    17. 9.4.5 Representing push streams with generators
    18. 9.4.6 Pipeable operators
    19. 9.4.7 Streamifying objects
    20. 9.4.8 Dynamic streamification
    21. 9.5 Closing thoughts
    22. Summary
  21. appendix A. Configuring Babel
  22. appendix B. Typed JavaScript<T>
    1. B.1 First, what?
    2. B.2 Benefits and drawbacks of statically typed JavaScript
    3. B.3 Type annotations
    4. B.3.1 Class types
    5. B.3.2 Interface types
    6. B.3.3 Object types
    7. B.3.4 Function types
    8. B.3.5 Generic types
    9. B.3.6 Union types
  23. index
  24. PATTERNS OF COMPOSABLE SOFTWARE