You are previewing You Don't Know JS: Types & Grammar.
O'Reilly logo
You Don't Know JS: Types & Grammar

Book Description

No matter how much experience you have with JavaScript, odds are you don’t fully understand the language. As part of the "You Don’t Know JS" series, this compact guide explores JavaScript types in greater depth than previous treatments by looking at type coercion problems, demonstrating why types work, and showing you how to take advantage of these features.

Table of Contents

  1. Foreword
  2. Preface
    1. Mission
    2. Review
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
  3. 1. Types
    1. A Type by Any Other Name…
    2. Built-in Types
    3. Values as Types
      1. undefined Versus “undeclared”
      2. typeof Undeclared
    4. Review
  4. 2. Values
    1. Arrays
      1. Array-Likes
    2. Strings
    3. Numbers
      1. Numeric Syntax
      2. Small Decimal Values
      3. Safe Integer Ranges
      4. Testing for Integers
      5. 32-Bit (Signed) Integers
    4. Special Values
      1. The Nonvalue Values
      2. Undefined
      3. Special Numbers
      4. Special Equality
    5. Value Versus Reference
    6. Review
  5. 3. Natives
    1. Internal [[Class]]
    2. Boxing Wrappers
      1. Object Wrapper Gotchas
    3. Unboxing
    4. Natives as Constructors
      1. Array(..)
      2. Object(..), Function(..), and RegExp(..)
      3. Date(..) and Error(..)
      4. Symbol(..)
      5. Native Prototypes
    5. Review
  6. 4. Coercion
    1. Converting Values
    2. Abstract Value Operations
      1. ToString
      2. ToNumber
      3. ToBoolean
    3. Explicit Coercion
      1. Explicitly: Strings <--> Numbers
      2. Explicitly: Parsing Numeric Strings
      3. Explicitly: * --> Boolean
    4. Implicit Coercion
      1. Simplifying Implicitly
      2. Implicitly: Strings <--> Numbers
      3. Implicitly: Booleans --> Numbers
      4. Implicitly: * --> Boolean
      5. Operators || and &&
      6. Symbol Coercion
    5. Loose Equals Versus Strict Equals
      1. Equality Performance
      2. Abstract Equality
      3. Edge Cases
    6. Abstract Relational Comparison
    7. Review
  7. 5. Grammar
    1. Statements & Expressions
      1. Statement Completion Values
      2. Expression Side Effects
      3. Contextual Rules
    2. Operator Precedence
      1. Short Circuited
      2. Tighter Binding
      3. Associativity
      4. Disambiguation
    3. Automatic Semicolons
      1. Error Correction
    4. Errors
      1. Using Variables Too Early
    5. Function Arguments
    6. try..finally
    7. switch
    8. Review
  8. A. Mixed Environment JavaScript
    1. Annex B (ECMAScript)
      1. Web ECMAScript
    2. Host Objects
    3. Global DOM Variables
    4. Native Prototypes
      1. Shims/Polyfills
    5. <script>s
    6. Reserved Words
    7. Implementation Limits
    8. Review
  9. B. Acknowledgments