JavaScript: The Definitive Guide: Master the World's Most-Used Programming Language

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

JavaScript is the programming language of the web and is used by more software developers today than any other programming language. For nearly 25 years this best seller has been the go-to guide for JavaScript programmers. The seventh edition is fully updated to cover the 2020 version of JavaScript, and new chapters cover classes, modules, iterators, generators, Promises, async/await, and metaprogramming. You’ll find illuminating and engaging example code throughout. This book is for programmers who want to learn JavaScript and for web developers who want to take their understanding and mastery to the next level. It begins by explaining the JavaScript language itself, in detail, from the bottom up. It then builds on that foundation to cover the web platform and Node.js. Topics include: • Types, values, variables, expressions, operators, statements, objects, and arrays • Functions, classes, modules, iterators, generators, Promises, and async/await • JavaScript’s standard library: data structures, regular expressions, JSON, i18n, etc. • The web platform: documents, components, graphics, networking, storage, and threads • Node.js: buffers, files, streams, threads, child processes, web clients, and web servers • Tools and language extensions that professional JavaScript developers rely on

Author(s): David Flanagan
Edition: 7
Publisher: O'Reilly Media
Year: 2020

Language: English
Pages: 706
City: Sebastopol, CA

Copyright
Table of Contents
Preface
Section 1. Conventions Used in This Book
Section 2. Example Code
Section 3. O’Reilly Online Learning
Section 4. How to Contact Us
Section 5. Acknowledgments
Chapter 1. Introduction to JavaScript
1.1 Exploring JavaScript
1.2 Hello World
1.3 A Tour of JavaScript
1.4 Example: Character Frequency Histograms
1.5 Summary
Chapter 2. Lexical Structure
2.1 The Text of a JavaScript Program
2.2 Comments
2.3 Literals
2.4 Identifiers and Reserved Words
2.4.1 Reserved Words
2.5 Unicode
2.5.1 Unicode Escape Sequences
2.5.2 Unicode Normalization
2.6 Optional Semicolons
2.7 Summary
Chapter 3. Types, Values, and Variables
3.1 Overview and Definitions
3.2 Numbers
3.2.1 Integer Literals
3.2.2 Floating-Point Literals
3.2.3 Arithmetic in JavaScript
3.2.4 Binary Floating-Point and Rounding Errors
3.2.5 Arbitrary Precision Integers with BigInt
3.2.6 Dates and Times
3.3 Text
3.3.1 String Literals
3.3.2 Escape Sequences in String Literals
3.3.3 Working with Strings
3.3.4 Template Literals
3.3.5 Pattern Matching
3.4 Boolean Values
3.5 null and undefined
3.6 Symbols
3.7 The Global Object
3.8 Immutable Primitive Values and Mutable Object References
3.9 Type Conversions
3.9.1 Conversions and Equality
3.9.2 Explicit Conversions
3.9.3 Object to Primitive Conversions
3.10 Variable Declaration and Assignment
3.10.1 Declarations with let and const
3.10.2 Variable Declarations with var
3.10.3 Destructuring Assignment
3.11 Summary
Chapter 4. Expressions and Operators
4.1 Primary Expressions
4.2 Object and Array Initializers
4.3 Function Definition Expressions
4.4 Property Access Expressions
4.4.1 Conditional Property Access
4.5 Invocation Expressions
4.5.1 Conditional Invocation
4.6 Object Creation Expressions
4.7 Operator Overview
4.7.1 Number of Operands
4.7.2 Operand and Result Type
4.7.3 Operator Side Effects
4.7.4 Operator Precedence
4.7.5 Operator Associativity
4.7.6 Order of Evaluation
4.8 Arithmetic Expressions
4.8.1 The + Operator
4.8.2 Unary Arithmetic Operators
4.8.3 Bitwise Operators
4.9 Relational Expressions
4.9.1 Equality and Inequality Operators
4.9.2 Comparison Operators
4.9.3 The in Operator
4.9.4 The instanceof Operator
4.10 Logical Expressions
4.10.1 Logical AND (&&)
4.10.2 Logical OR (||)
4.10.3 Logical NOT (!)
4.11 Assignment Expressions
4.11.1 Assignment with Operation
4.12 Evaluation Expressions
4.12.1 eval()
4.12.2 Global eval()
4.12.3 Strict eval()
4.13 Miscellaneous Operators
4.13.1 The Conditional Operator (?:)
4.13.2 First-Defined (??)
4.13.3 The typeof Operator
4.13.4 The delete Operator
4.13.5 The await Operator
4.13.6 The void Operator
4.13.7 The comma Operator (,)
4.14 Summary
Chapter 5. Statements
5.1 Expression Statements
5.2 Compound and Empty Statements
5.3 Conditionals
5.3.1 if
5.3.2 else if
5.3.3 switch
5.4 Loops
5.4.1 while
5.4.2 do/while
5.4.3 for
5.4.4 for/of
5.4.5 for/in
5.5 Jumps
5.5.1 Labeled Statements
5.5.2 break
5.5.3 continue
5.5.4 return
5.5.5 yield
5.5.6 throw
5.5.7 try/catch/finally
5.6 Miscellaneous Statements
5.6.1 with
5.6.2 debugger
5.6.3 “use strict”
5.7 Declarations
5.7.1 const, let, and var
5.7.2 function
5.7.3 class
5.7.4 import and export
5.8 Summary of JavaScript Statements
Chapter 6. Objects
6.1 Introduction to Objects
6.2 Creating Objects
6.2.1 Object Literals
6.2.2 Creating Objects with new
6.2.3 Prototypes
6.2.4 Object.create()
6.3 Querying and Setting Properties
6.3.1 Objects As Associative Arrays
6.3.2 Inheritance
6.3.3 Property Access Errors
6.4 Deleting Properties
6.5 Testing Properties
6.6 Enumerating Properties
6.6.1 Property Enumeration Order
6.7 Extending Objects
6.8 Serializing Objects
6.9 Object Methods
6.9.1 The toString() Method
6.9.2 The toLocaleString() Method
6.9.3 The valueOf() Method
6.9.4 The toJSON() Method
6.10 Extended Object Literal Syntax
6.10.1 Shorthand Properties
6.10.2 Computed Property Names
6.10.3 Symbols as Property Names
6.10.4 Spread Operator
6.10.5 Shorthand Methods
6.10.6 Property Getters and Setters
6.11 Summary
Chapter 7. Arrays
7.1 Creating Arrays
7.1.1 Array Literals
7.1.2 The Spread Operator
7.1.3 The Array() Constructor
7.1.4 Array.of()
7.1.5 Array.from()
7.2 Reading and Writing Array Elements
7.3 Sparse Arrays
7.4 Array Length
7.5 Adding and Deleting Array Elements
7.6 Iterating Arrays
7.7 Multidimensional Arrays
7.8 Array Methods
7.8.1 Array Iterator Methods
7.8.2 Flattening arrays with flat() and flatMap()
7.8.3 Adding arrays with concat()
7.8.4 Stacks and Queues with push(), pop(), shift(), and unshift()
7.8.5 Subarrays with slice(), splice(), fill(), and copyWithin()
7.8.6 Array Searching and Sorting Methods
7.8.7 Array to String Conversions
7.8.8 Static Array Functions
7.9 Array-Like Objects
7.10 Strings as Arrays
7.11 Summary
Chapter 8. Functions
8.1 Defining Functions
8.1.1 Function Declarations
8.1.2 Function Expressions
8.1.3 Arrow Functions
8.1.4 Nested Functions
8.2 Invoking Functions
8.2.1 Function Invocation
8.2.2 Method Invocation
8.2.3 Constructor Invocation
8.2.4 Indirect Invocation
8.2.5 Implicit Function Invocation
8.3 Function Arguments and Parameters
8.3.1 Optional Parameters and Defaults
8.3.2 Rest Parameters and Variable-Length Argument Lists
8.3.3 The Arguments Object
8.3.4 The Spread Operator for Function Calls
8.3.5 Destructuring Function Arguments into Parameters
8.3.6 Argument Types
8.4 Functions as Values
8.4.1 Defining Your Own Function Properties
8.5 Functions as Namespaces
8.6 Closures
8.7 Function Properties, Methods, and Constructor
8.7.1 The length Property
8.7.2 The name Property
8.7.3 The prototype Property
8.7.4 The call() and apply() Methods
8.7.5 The bind() Method
8.7.6 The toString() Method
8.7.7 The Function() Constructor
8.8 Functional Programming
8.8.1 Processing Arrays with Functions
8.8.2 Higher-Order Functions
8.8.3 Partial Application of Functions
8.8.4 Memoization
8.9 Summary
Chapter 9. Classes
9.1 Classes and Prototypes
9.2 Classes and Constructors
9.2.1 Constructors, Class Identity, and instanceof
9.2.2 The constructor Property
9.3 Classes with the class Keyword
9.3.1 Static Methods
9.3.2 Getters, Setters, and other Method Forms
9.3.3 Public, Private, and Static Fields
9.3.4 Example: A Complex Number Class
9.4 Adding Methods to Existing Classes
9.5 Subclasses
9.5.1 Subclasses and Prototypes
9.5.2 Subclasses with extends and super
9.5.3 Delegation Instead of Inheritance
9.5.4 Class Hierarchies and Abstract Classes
9.6 Summary
Chapter 10. Modules
10.1 Modules with Classes, Objects, and Closures
10.1.1 Automating Closure-Based Modularity
10.2 Modules in Node
10.2.1 Node Exports
10.2.2 Node Imports
10.2.3 Node-Style Modules on the Web
10.3 Modules in ES6
10.3.1 ES6 Exports
10.3.2 ES6 Imports
10.3.3 Imports and Exports with Renaming
10.3.4 Re-Exports
10.3.5 JavaScript Modules on the Web
10.3.6 Dynamic Imports with import()
10.3.7 import.meta.url
10.4 Summary
Chapter 11. The JavaScript Standard Library
11.1 Sets and Maps
11.1.1 The Set Class
11.1.2 The Map Class
11.1.3 WeakMap and WeakSet
11.2 Typed Arrays and Binary Data
11.2.1 Typed Array Types
11.2.2 Creating Typed Arrays
11.2.3 Using Typed Arrays
11.2.4 Typed Array Methods and Properties
11.2.5 DataView and Endianness
11.3 Pattern Matching with Regular Expressions
11.3.1 Defining Regular Expressions
11.3.2 String Methods for Pattern Matching
11.3.3 The RegExp Class
11.4 Dates and Times
11.4.1 Timestamps
11.4.2 Date Arithmetic
11.4.3 Formatting and Parsing Date Strings
11.5 Error Classes
11.6 JSON Serialization and Parsing
11.6.1 JSON Customizations
11.7 The Internationalization API
11.7.1 Formatting Numbers
11.7.2 Formatting Dates and Times
11.7.3 Comparing Strings
11.8 The Console API
11.8.1 Formatted Output with Console
11.9 URL APIs
11.9.1 Legacy URL Functions
11.10 Timers
11.11 Summary
Chapter 12. Iterators and Generators
12.1 How Iterators Work
12.2 Implementing Iterable Objects
12.2.1 “Closing” an Iterator: The Return Method
12.3 Generators
12.3.1 Generator Examples
12.3.2 yield* and Recursive Generators
12.4 Advanced Generator Features
12.4.1 The Return Value of a Generator Function
12.4.2 The Value of a yield Expression
12.4.3 The return() and throw() Methods of a Generator
12.4.4 A Final Note About Generators
12.5 Summary
Chapter 13. Asynchronous JavaScript
13.1 Asynchronous Programming with Callbacks
13.1.1 Timers
13.1.2 Events
13.1.3 Network Events
13.1.4 Callbacks and Events in Node
13.2 Promises
13.2.1 Using Promises
13.2.2 Chaining Promises
13.2.3 Resolving Promises
13.2.4 More on Promises and Errors
13.2.5 Promises in Parallel
13.2.6 Making Promises
13.2.7 Promises in Sequence
13.3 async and await
13.3.1 await Expressions
13.3.2 async Functions
13.3.3 Awaiting Multiple Promises
13.3.4 Implementation Details
13.4 Asynchronous Iteration
13.4.1 The for/await Loop
13.4.2 Asynchronous Iterators
13.4.3 Asynchronous Generators
13.4.4 Implementing Asynchronous Iterators
13.5 Summary
Chapter 14. Metaprogramming
14.1 Property Attributes
14.2 Object Extensibility
14.3 The prototype Attribute
14.4 Well-Known Symbols
14.4.1 Symbol.iterator and Symbol.asyncIterator
14.4.2 Symbol.hasInstance
14.4.3 Symbol.toStringTag
14.4.4 Symbol.species
14.4.5 Symbol.isConcatSpreadable
14.4.6 Pattern-Matching Symbols
14.4.7 Symbol.toPrimitive
14.4.8 Symbol.unscopables
14.5 Template Tags
14.6 The Reflect API
14.7 Proxy Objects
14.7.1 Proxy Invariants
14.8 Summary
Chapter 15. JavaScript in Web Browsers
15.1 Web Programming Basics
15.1.1 JavaScript in HTML