Cover image for You Don't Know JS: this & Object Prototypes

Book description

No matter how much experience you have with JavaScript, odds are you don’t fully understand the language. This concise, in-depth guide takes you inside JavaScript’s this structure and object prototypes. You’ll learn how they work and why they’re integral to behavior delegation—a design pattern in which objects are linked, rather than cloned. Like other books in the "You Don’t Know JS" series, this and Object Prototypes dives into trickier parts of the language that many JavaScript programmers simply avoid.

Table of Contents

  1. Foreword
  2. Preface
    1. Mission
    2. Review (TL;DR)
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
  3. 1.
    1. Why
    2. Confusions
      1. Itself
      2. Its Scope
    3. What’s
    4. Review (TL;DR)
  4. 2.
    1. Call-site
    2. Nothing But Rules
      1. Default Binding
      2. Implicit Binding
        1. Implicitly Lost
      3. Explicit Binding
        1. Hard Binding
        2. API call “contexts”
      4. Binding
    3. Everything In Order
      1. Determining
    4. Binding Exceptions
      1. Ignored
      2. Indirection
      3. Softening Binding
    5. Lexical
    6. Review (TL;DR)
  5. 3. Objects
    1. Syntax
    2. Type
      1. Built-in Objects
    3. Contents
      1. Computed Property Names
      2. Property vs. Method
      3. Arrays
      4. Duplicating Objects
      5. Property Descriptors
        1. Writable
        2. Configurable
        3. Enumerable
      6. Immutability
        1. Object Constant
        2. Prevent Extensions
        3. Seal
        4. Freeze
      7. Getters & Setters
      8. Existence
        1. Enumeration
    4. Iteration
    5. Review (TL;DR)
  6. 4. Mixing (Up) “Class” Objects
    1. Class Theory
      1. “Class” Design Pattern
      2. JavaScript “Classes”
    2. Class Mechanics
      1. Building
      2. Constructor
    3. Class Inheritance
      1. Polymorphism
      2. Multiple Inheritance
    4. Mixins
      1. Explicit Mixins
        1. “Polymorphism” Revisited
        2. Mixing Copies
        3. Parasitic Inheritance
      2. Implicit Mixins
    5. Review (TL;DR)
  7. 5. Prototypes
      1. Setting & Shadowing Properties
    1. “Class”
      1. “Class” Functions
        1. What’s in a name?
      2. “Constructors”
        1. Constructor Or Call?
      3. Mechanics
        1. “Constructor” Redux
    2. “(Prototypal) Inheritance”
      1. Reflection
    3. Object Links
      1. `Create()`ing Links
        1. Polyfilled
      2. Links As Fallbacks?
    4. Review (TL;DR)
  8. 6. Behavior Delegation
    1. Towards Delegation-Oriented Design
      1. Class Theory
      2. Delegation Theory
        1. Mutual Delegation (Disallowed)
        2. Debugged
      3. Mental Models Compared
    2. Classes vs. Objects
      1. Widget “Classes”
        1. ES6
      2. Delegating Widget Objects
    3. Simpler Design
      1. De-class-ified
    4. Nicer Syntax
      1. Unlexical
    5. Introspection
    6. Review (TL;DR)
  9. A. ES6
    1. Gotchas
    2. Static > Dynamic?
    3. Review (TL;DR)
  10. B. Thank Yous!
  11. Index
  12. About the Author
  13. Colophon
  14. Copyright