0%

Book Description

For web developers and other programmers interested in using JavaScript, this bestselling book provides the most comprehensive JavaScript reference section on the market. The seventh edition represents a significant update, with new material for ECMAScript 2017 (ES8), and new chapters on language-specific features.

JavaScript: The Definitive Guide is ideal for experienced programmers who want to learn the programming language of the web, and for current JavaScript programmers who want to master it.

Table of Contents

  1. Preface
    1. Conventions Used in This Book
    2. Example Code
    3. Errata and How to Contact Us
    4. Acknowledgments
  2. Lexical Structure
    1. 1.1 The Text of a JavaScript Program
    2. 1.2 Comments
    3. 1.3 Literals
    4. 1.4 Identifiers and Reserved Words
      1. 1.4.1 Reserved Words
    5. 1.5 Unicode
      1. 1.5.1 Unicode Escape Sequences
      2. 1.5.2 Unicode Normalization
    6. 1.6 Optional Semicolons
    7. 1.7 Summary
  3. Types, Values, and Variables
    1. 2.0 Introduction
    2. 2.1 Numbers
      1. 2.2.1 Integer Literals
      2. 2.2.2 Floating-Point Literals
      3. 2.2.3 Arithmetic in JavaScript
      4. 2.2.4 Binary Floating-Point and Rounding Errors
      5. 2.2.5 Arbitrary Precision Integers with BigInt
      6. 2.2.6 Dates and Times
    3. 2.2 Text
      1. 2.3.1 String Literals
      2. 2.3.2 Escape Sequences in String Literals
      3. 2.3.3 Working with Strings
      4. 2.3.4 Template Literals
      5. 2.3.5 Pattern Matching
    4. 2.3 Boolean Values
    5. 2.4 null and undefined
    6. 2.5 Symbols
    7. 2.6 The Global Object
    8. 2.7 Immutable Primitive Values and Mutable Object References
    9. 2.8 Type Conversions
      1. 2.9.1 Conversions and Equality
      2. 2.9.2 Explicit Conversions
      3. 2.9.3 Object to Primitive Conversions
    10. 2.9 Variable Declaration and Assignment
      1. 2.10.1 Declarations with let and const
      2. 2.10.2 Variable Declarations with var
      3. 2.10.3 Destructuring Assignment
    11. 2.10 Summary
  4. Expressions and Operators
    1. 3.1 Primary Expressions
    2. 3.2 Object and Array Initializers
    3. 3.3 Function Definition Expressions
    4. 3.4 Property Access Expressions
    5. 3.5 Invocation Expressions
    6. 3.6 Object Creation Expressions
    7. 3.7 Operator Overview
      1. 3.7.1 Number of Operands
      2. 3.7.2 Operand and Result Type
      3. 3.7.3 Lvalues
      4. 3.7.4 Operator Side Effects
      5. 3.7.5 Operator Precedence
      6. 3.7.6 Operator Associativity
      7. 3.7.7 Order of Evaluation
    8. 3.8 Arithmetic Expressions
      1. 3.8.1 The + Operator
      2. 3.8.2 Unary Arithmetic Operators
      3. 3.8.3 Bitwise Operators
    9. 3.9 Relational Expressions
      1. 3.9.1 Equality and Inequality Operators
      2. 3.9.2 Comparison Operators
      3. 3.9.3 The in Operator
      4. 3.9.4 The instanceof Operator
    10. 3.10 Logical Expressions
      1. 3.10.1 Logical AND (&&)
      2. 3.10.2 Logical OR (||)
      3. 3.10.3 Logical NOT (!)
    11. 3.11 Assignment Expressions
      1. 3.11.1 Assignment with Operation
    12. 3.12 Evaluation Expressions
      1. 3.12.1 eval()
      2. 3.12.2 Global eval()
      3. 3.12.3 Strict eval()
    13. 3.13 Miscellaneous Operators
      1. 3.13.1 The Conditional Operator (?:)
      2. 3.13.2 The typeof Operator
      3. 3.13.3 The delete Operator
      4. 3.13.4 The await Operator
      5. 3.13.5 The void Operator
      6. 3.13.6 The Comma Operator (,)
    14. 3.14 Summary
  5. Statements
    1. 4.1 Expression Statements
    2. 4.2 Compound and Empty Statements
    3. 4.3 Conditionals
      1. 4.3.1 if
      2. 4.3.2 else if
      3. 4.3.3 switch
    4. 4.4 Loops
      1. 4.4.1 while
      2. 4.4.2 do/while
      3. 4.4.3 for
      4. 4.4.4 for/of
      5. 4.4.5 for/in
    5. 4.5 Jumps
      1. 4.5.1 Labeled Statements
      2. 4.5.2 break
      3. 4.5.3 continue
      4. 4.5.4 return
      5. 4.5.5 yield
      6. 4.5.6 throw
      7. 4.5.7 try/catch/finally
    6. 4.6 Miscellaneous Statements
      1. 4.6.1 with
      2. 4.6.2 debugger
      3. 4.6.3 “use strict”
    7. 4.7 Declarations
      1. 4.7.1 const, let and var
      2. 4.7.2 function
      3. 4.7.3 class
      4. 4.7.4 import and export
    8. 4.8 Summary of JavaScript Statements
  6. Objects
    1. 5.1 Introduction to Objects
    2. 5.2 Creating Objects
      1. 5.2.1 Object Literals
      2. 5.2.2 Creating Objects with new
      3. 5.2.3 Prototypes
      4. 5.2.4 Object.create()
    3. 5.3 Querying and Setting Properties
      1. 5.3.1 Objects As Associative Arrays
      2. 5.3.2 Inheritance
      3. 5.3.3 Property Access Errors
    4. 5.4 Deleting Properties
    5. 5.5 Testing Properties
    6. 5.6 Enumerating Properties
      1. 5.6.1 Property Enumeration Order
    7. 5.7 Extending Objects
    8. 5.8 Serializing Objects
    9. 5.9 Object Methods
      1. 5.9.1 The toString() Method
      2. 5.9.2 The toLocaleString() Method
      3. 5.9.3 The valueOf() Method
      4. 5.9.4 The toJSON() Method
    10. 5.10 Extended Object Literal Syntax
      1. 5.10.1 Shorthand Properties
      2. 5.10.2 Computed Property Names
      3. 5.10.3 Symbols as Property Names
      4. 5.10.4 Spread Operator
      5. 5.10.5 Shorthand Methods
      6. 5.10.6 Property Getters and Setters
    11. 5.11 Summary
  7. Arrays
    1. 6.1 Creating Arrays
      1. 6.1.1 Array Literals
      2. 6.1.2 The Spread Operator
      3. 6.1.3 The Array() Constructor
      4. 6.1.4 Array.of()
      5. 6.1.5 Array.from()
    2. 6.2 Reading and Writing Array Elements
    3. 6.3 Sparse Arrays
    4. 6.4 Array Length
    5. 6.5 Adding and Deleting Array Elements
    6. 6.6 Iterating Arrays
    7. 6.7 Multidimensional Arrays
    8. 6.8 Array Methods
      1. 6.8.1 Array Iterator Methods
      2. 6.8.2 Adding arrays with concat()
      3. 6.8.3 Stacks and Queues with push(), pop(), shift() and unshift()
      4. 6.8.4 Subarrays with slice(), splice(), fill() and copyWithin()
      5. 6.8.5 Array Searching and Sorting Methods
      6. 6.8.6 Array to String Conversions
      7. 6.8.7 Static Array Functions
    9. 6.9 Array-Like Objects
    10. 6.10 Strings As Arrays
    11. 6.11 Summary
  8. Functions
    1. 7.1 Defining Functions
      1. 7.1.1 Function Declarations
      2. 7.1.2 Function Expressions
      3. 7.1.3 Arrow Functions
      4. 7.1.4 Nested Functions
    2. 7.2 Invoking Functions
      1. 7.2.1 Function Invocation
      2. 7.2.2 Method Invocation
      3. 7.2.3 Constructor Invocation
      4. 7.2.4 Indirect Invocation
      5. 7.2.5 Implicit Function Invocation
    3. 7.3 Function Arguments and Parameters
      1. 7.3.1 Optional Parameters and Defaults
      2. 7.3.2 Rest Parameters and Variable-Length Argument Lists
      3. 7.3.3 The Arguments Object
      4. 7.3.4 The Spread Operator for Function Calls
      5. 7.3.5 Destructuring Function Arguments into Parameters
      6. 7.3.6 Argument Types
    4. 7.4 Functions As Values
      1. 7.4.1 Defining Your Own Function Properties
    5. 7.5 Functions As Namespaces
    6. 7.6 Closures
    7. 7.7 Function Properties, Methods, and Constructor
      1. 7.7.1 The length Property
      2. 7.7.2 The name Property
      3. 7.7.3 The prototype Property
      4. 7.7.4 The call() and apply() Methods
      5. 7.7.5 The bind() Method
      6. 7.7.6 The toString() Method
      7. 7.7.7 The Function() Constructor
    8. 7.8 Functional Programming
      1. 7.8.1 Processing Arrays with Functions
      2. 7.8.2 Higher-Order Functions
      3. 7.8.3 Partial Application of Functions
      4. 7.8.4 Memoization
    9. 7.9 Summary
  9. Classes
    1. 8.1 Classes and Prototypes
    2. 8.2 Classes and Constructors
      1. 8.2.1 Constructors, Class Identity and instanceof
      2. 8.2.2 The constructor Property
    3. 8.3 Classes with the class Keyword
      1. 8.3.1 Static Methods
      2. 8.3.2 Getters, Setters and other Method Forms
      3. 8.3.3 Public, Private and Static Fields
      4. 8.3.4 Example: a Complex Number Class
    4. 8.4 Adding Methods to Existing Classes
    5. 8.5 Subclasses
      1. 8.5.1 Subclasses and Prototypes
      2. 8.5.2 Subclasses with extends and super
      3. 8.5.3 Delegation Instead of Inheritance
      4. 8.5.4 Class Hierarchies and Abstract Classes
    6. 8.6 Summary
  10. The JavaScript Standard Library
    1. 9.1 Sets and Maps
      1. 9.1.1 The Set Class
      2. 9.1.2 The Map Class
      3. 9.1.3 WeakMap and WeakSet
    2. 9.2 Typed Arrays and Binary Data
      1. 9.2.1 Typed Array Types
      2. 9.2.2 Creating Typed Arrays
      3. 9.2.3 Using Typed Arrays
      4. 9.2.4 Typed Array Methods
      5. 9.2.5 DataView and Endianness
    3. 9.3 Pattern Matching with Regular Expressions
      1. 9.3.1 Defining Regular Expressions
      2. 9.3.2 String Methods for Pattern Matching
      3. 9.3.3 The RegExp Class
    4. 9.4 Dates and Times
      1. 9.4.1 Timestamps and Date Arithmetic
      2. 9.4.2 Formatting and Parsing Date Strings
    5. 9.5 Error Classes
    6. 9.6 JSON Serialization and Parsing
      1. 9.6.1 JSON Customizations
    7. 9.7 The Internationalization API
      1. 9.7.1 Formatting Numbers
      2. 9.7.2 Formatting Dates and Times
      3. 9.7.3 Comparing Strings
    8. 9.8 The Console API
    9. 9.9 URL APIs
      1. 9.9.1 Legacy URL Functions
    10. 9.10 Timers
  11. Iterators and Generators
    1. 10.1 How iterators work
    2. 10.2 Implementing Iterable Objects
      1. 10.2.1 “Closing” an iterator: the return method
    3. 10.3 Generators
      1. 10.3.1 Generator Examples
      2. 10.3.2 yield* and Recursive Generators
    4. 10.4 Advanced Generator Features
      1. 10.4.1 The Return Value of a Generator Function
      2. 10.4.2 The Value of a yield Expression
      3. 10.4.3 The return() and throw() Methods of a Generator
      4. 10.4.4 A Final Note about Generators
    5. 10.5 Summary
  12. Asynchronous JavaScript
    1. 11.1 Asynchronous Programming with Callbacks
      1. 11.1.1 Timers
      2. 11.1.2 Events
      3. 11.1.3 Network Events
      4. 11.1.4 Callbacks and Events in Node
    2. 11.2 Promises
      1. 11.2.1 Using Promises
      2. 11.2.2 Chaining Promises
      3. 11.2.3 Resolving Promises
      4. 11.2.4 More on Promises and Errors
      5. 11.2.5 Promises in Parallel
      6. 11.2.6 Making Promises
      7. 11.2.7 Promises in Sequence
    3. 11.3 async and await
      1. 11.3.1 await Expressions
      2. 11.3.2 async Functions
      3. 11.3.3 Awaiting Multiple Promises
      4. 11.3.4 Implementation Details
    4. 11.4 Asynchronous Iteration
      1. 11.4.1 The for/await Loop
      2. 11.4.2 Asynchronous Iterators
      3. 11.4.3 Asynchronous Generators
      4. 11.4.4 Implementing Asynchronous Iterators
    5. 11.5 Summary
3.142.197.212