Understanding ECMAScript 6

Book description

Understanding ECMAScript 6 is your roadmap to the new object types, syntax, and other exciting features in the latest version of JavaScript.

Publisher resources

View/Submit Errata

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Brief Contents
  5. Contents in Detail
  6. Foreword
  7. Acknowledgments
  8. Introduction
    1. The Road to ECMAScript 6
    2. About This Book
      1. Browser and Node.js Compatibility
      2. Who This Book Is For
      3. Overview
      4. Conventions Used
      5. Help and Support
  9. Chapter 1: Block Bindings
    1. var Declarations and Hoisting
    2. Block-Level Declarations
      1. let Declarations
      2. No Redeclaration
      3. const Declarations
      4. The Temporal Dead Zone
    3. Block Bindings in Loops
      1. Functions in Loops
      2. let Declarations in Loops
      3. const Declarations in Loops
    4. Global Block Bindings
    5. Emerging Best Practices for Block Bindings
    6. Summary
  10. Chapter 2: Strings and Regular Expressions
    1. Better Unicode Support
      1. UTF-16 Code Points
      2. The codePointAt() Method
      3. The String.fromCodePoint() Method
      4. The normalize() Method
      5. The Regular Expression u Flag
    2. Other String Changes
      1. Methods for Identifying Substrings
      2. The repeat() Method
    3. Other Regular Expression Changes
      1. The Regular Expression y Flag
      2. Duplicating Regular Expressions
      3. The flags Property
    4. Template Literals
      1. Basic Syntax
      2. Multiline Strings
      3. Making Substitutions
      4. Tagged Templates
    5. Summary
  11. Chapter 3: Functions
    1. Functions with Default Parameter Values
      1. Simulating Default Parameter Values in ECMAScript 5
      2. Default Parameter Values in ECMAScript 6
      3. How Default Parameter Values Affect the arguments Object
      4. Default Parameter Expressions
      5. Default Parameter TDZ
    2. Working with Unnamed Parameters
      1. Unnamed Parameters in ECMAScript 5
      2. Rest Parameters
    3. Increased Capabilities of the Function Constructor
    4. The Spread Operator
    5. The name Property
      1. Choosing Appropriate Names
      2. Special Cases of the name Property
    6. Clarifying the Dual Purpose of Functions
      1. Determining How a Function Was Called in ECMAScript 5
      2. The new.target Metaproperty
    7. Block-Level Functions
      1. Deciding When to Use Block-Level Functions
      2. Block-Level Functions in Non-Strict Mode
    8. Arrow Functions
      1. Arrow Function Syntax
      2. Creating Immediately Invoked Function Expressions
      3. No this Binding
      4. Arrow Functions and Arrays
      5. No arguments Binding
      6. Identifying Arrow Functions
    9. Tail Call Optimization
      1. How Tail Calls Are Different in ECMAScript 6
      2. How to Harness Tail Call Optimization
    10. Summary
  12. Chapter 4: Expanded Object Functionality
    1. Object Categories
    2. Object Literal Syntax Extensions
      1. Property Initializer Shorthand
      2. Concise Methods
      3. Computed Property Names
    3. New Methods
      1. The Object.is() Method
      2. The Object.assign() Method
    4. Duplicate Object Literal Properties
    5. Own Property Enumeration Order
    6. Enhancements for Prototypes
      1. Changing an Object’s Prototype
      2. Easy Prototype Access with Super References
    7. A Formal Method Definition
    8. Summary
  13. Chapter 5: Destructuring for Easier Data Access
    1. Why Is Destructuring Useful?
    2. Object Destructuring
      1. Destructuring Assignment
      2. Default Values
      3. Assigning to Different Local Variable Names
      4. Nested Object Destructuring
    3. Array Destructuring
      1. Destructuring Assignment
      2. Default Values
      3. Nested Array Destructuring
      4. Rest Items
    4. Mixed Destructuring
    5. Destructured Parameters
      1. Destructured Parameters Are Required
      2. Default Values for Destructured Parameters
    6. Summary
  14. Chapter 6: Symbols and Symbol Properties
    1. Creating Symbols
    2. Using Symbols
    3. Sharing Symbols
    4. Symbol Coercion
    5. Retrieving Symbol Properties
    6. Exposing Internal Operations with Well-Known Symbols
      1. The Symbol.hasInstance Method
      2. The Symbol.isConcatSpreadable Property
      3. The Symbol.match, Symbol.replace, Symbol.search, and Symbol.split Properties
      4. The Symbol.toPrimitive Method
      5. The Symbol.toStringTag Property
      6. The Symbol.unscopables Property
    7. Summary
  15. Chapter 7: Sets and Maps
    1. Sets and Maps in ECMAScript 5
    2. Problems with Workarounds
    3. Sets in ECMAScript 6
      1. Creating Sets and Adding Items
      2. Removing Items
      3. The forEach() Method for Sets
      4. Converting a Set to an Array
      5. Weak Sets
    4. Maps in ECMAScript 6
      1. Map Methods
      2. Map Initialization
      3. The forEach() Method for Maps
      4. Weak Maps
    5. Summary
  16. Chapter 8: Iterators and Generators
    1. The Loop Problem
    2. What Are Iterators?
    3. What Are Generators?
      1. Generator Function Expressions
      2. Generator Object Methods
    4. Iterables and for-of Loops
      1. Accessing the Default Iterator
      2. Creating Iterables
    5. Built-In Iterators
      1. Collection Iterators
      2. String Iterators
      3. NodeList Iterators
    6. The Spread Operator and Nonarray Iterables
    7. Advanced Iterator Functionality
      1. Passing Arguments to Iterators
      2. Throwing Errors in Iterators
      3. Generator Return Statements
      4. Delegating Generators
    8. Asynchronous Task Running
      1. A Simple Task Runner
      2. Task Running with Data
      3. An Asynchronous Task Runner
    9. Summary
  17. Chapter 9: Introducing JavaScript Classes
    1. Class-Like Structures in ECMAScript 5
    2. Class Declarations
      1. A Basic Class Declaration
      2. Why Use the Class Syntax?
    3. Class Expressions
      1. A Basic Class Expression
      2. Named Class Expressions
    4. Classes as First-Class Citizens
    5. Accessor Properties
    6. Computed Member Names
    7. Generator Methods
    8. Static Members
    9. Inheritance with Derived Classes
      1. Shadowing Class Methods
      2. Inherited Static Members
      3. Derived Classes from Expressions
      4. Inheriting from Built-Ins
      5. The Symbol.species Property
    10. Using new.target in Class Constructors
    11. Summary
  18. Chapter 10: Improved Array Capabilities
    1. Creating Arrays
      1. The Array.of() Method
      2. The Array.from() Method
    2. New Methods on All Arrays
      1. The find() and findIndex() Methods
      2. The fill() Method
      3. The copyWithin() Method
    3. Typed Arrays
      1. Numeric Data Types
      2. Array Buffers
      3. Manipulating Array Buffers with Views
    4. Similarities Between Typed and Regular Arrays
      1. Common Methods
      2. The Same Iterators
      3. The of() and from() Methods
    5. Differences Between Typed and Regular Arrays
      1. Behavioral Differences
      2. Missing Methods
      3. Additional Methods
    6. Summary
  19. Chapter 11: Promises and Asynchronous Programming
    1. Asynchronous Programming Background
      1. The Event Model
      2. The Callback Pattern
    2. Promise Basics
      1. The Promise Life Cycle
      2. Creating Unsettled Promises
      3. Creating Settled Promises
      4. Executor Errors
    3. Global Promise Rejection Handling
      1. Node.js Rejection Handling
      2. Browser Rejection Handling
    4. Chaining Promises
      1. Catching Errors
      2. Returning Values in Promise Chains
      3. Returning Promises in Promise Chains
    5. Responding to Multiple Promises
      1. The Promise.all() Method
      2. The Promise.race() Method
    6. Inheriting from Promises
    7. Promise-Based Asynchronous Task Running
    8. Summary
  20. Chapter 12: Proxies and the Reflection API
    1. The Array Problem
    2. Introducing Proxies and Reflection
    3. Creating a Simple Proxy
    4. Validating Properties Using the set Trap
    5. Object Shape Validation Using the get Trap
    6. Hiding Property Existence Using the has Trap
    7. Preventing Property Deletion with the deleteProperty Trap
    8. Prototype Proxy Traps
      1. How Prototype Proxy Traps Work
      2. Why Two Sets of Methods?
    9. Object Extensibility Traps
      1. Two Basic Examples
      2. Duplicate Extensibility Methods
    10. Property Descriptor Traps
      1. Blocking Object.defineProperty()
      2. Descriptor Object Restrictions
      3. Duplicate Descriptor Methods
    11. The ownKeys Trap
    12. Function Proxies with the apply and construct Traps
      1. Validating Function Parameters
      2. Calling Constructors Without new
      3. Overriding Abstract Base Class Constructors
      4. Callable Class Constructors
    13. Revocable Proxies
    14. Solving the Array Problem
      1. Detecting Array Indexes
      2. Increasing length When Adding New Elements
      3. Deleting Elements When Reducing length
      4. Implementing the MyArray Class
    15. Using a Proxy as a Prototype
      1. Using the get Trap on a Prototype
      2. Using the set Trap on a Prototype
      3. Using the has Trap on a Prototype
      4. Proxies as Prototypes on Classes
    16. Summary
  21. Chapter 13: Encapsulating Code with Modules
    1. What Are Modules?
    2. Basic Exporting
    3. Basic Importing
      1. Importing a Single Binding
      2. Importing Multiple Bindings
      3. Importing an Entire Module
      4. A Subtle Quirk of Imported Bindings
    4. Renaming Exports and Imports
    5. Default Values in Modules
      1. Exporting Default Values
      2. Importing Default Values
    6. Re-exporting a Binding
    7. Importing Without Bindings
    8. Loading Modules
      1. Using Modules in Web Browsers
      2. Browser Module Specifier Resolution
    9. Summary
  22. Appendix A: Minor Changes in ECMAScript 6
    1. Working with Integers
      1. Identifying Integers
      2. Safe Integers
    2. New Math Methods
    3. Unicode Identifiers
    4. Formalizing the __proto__ Property
  23. Appendix B: Understanding ECMAScript 7 (2016)
    1. The Exponentiation Operator
      1. Order of Operations
      2. Operand Restriction
    2. The Array.prototype.includes() Method
      1. How to Use Array.prototype.includes()
      2. Value Comparison
    3. A Change to Function-Scoped Strict Mode
  24. Index
  25. Updates
  26. Level Up Your JavaScript

Product information

  • Title: Understanding ECMAScript 6
  • Author(s): Nicholas C. Zakas
  • Release date: August 2016
  • Publisher(s): No Starch Press
  • ISBN: 9781593277574