Homepage
Please support this book:
buy it
or
donate
(Ad, please don’t block.)
Deep JavaScript
Table of contents
I Frontmatter
1 About this book
1.1 Where is the homepage of this book?
1.2 What is in this book?
1.3 What do I get for my money?
1.4 How can I preview the content?
1.5 How do I report errors?
1.6 Tips for reading
1.7 Notations and conventions
1.8 Acknowledgements
II Types, values, variables
2 Type coercion in JavaScript
2.1 What is type coercion?
2.2 Operations that help implement coercion in the ECMAScript specification
2.3 Intermission: expressing specification algorithms in JavaScript
2.4 Example coercion algorithms
2.5 Operations that coerce
2.6 Glossary: terms related to type conversion
3 The destructuring algorithm
3.1 Preparing for the pattern matching algorithm
3.2 The pattern matching algorithm
3.3 Empty object patterns and Array patterns
3.4 Applying the algorithm
4 Environments: under the hood of variables
4.1 Environment: data structure for managing variables
4.2 Recursion via environments
4.3 Nested scopes via environments
4.4 Closures and environments
5 A detailed look at global variables
5.1 Scopes
5.2 Lexical environments
5.3 The global object
5.4 In browsers,
globalThis
does not point directly to the global object
5.5 The global environment
5.6 Conclusion: Why does JavaScript have both normal global variables and the global object?
5.7 Further reading and sources of this chapter
III Working with data
6 Copying objects and Arrays
6.1 Shallow copying vs. deep copying
6.2 Shallow copying in JavaScript
6.3 Deep copying in JavaScript
6.4 Further reading
7 Updating data destructively and non-destructively
7.1 Examples: updating an object destructively and non-destructively
7.2 Examples: updating an Array destructively and non-destructively
7.3 Manual deep updating
7.4 Implementing generic deep updating
8 The problems of shared mutable state and how to avoid them
8.1 What is shared mutable state and why is it problematic?
8.2 Avoiding sharing by copying data
8.3 Avoiding mutations by updating non-destructively
8.4 Preventing mutations by making data immutable
8.5 Libraries for avoiding shared mutable state
IV OOP: object property attributes
9 Property attributes: an introduction
9.1 The structure of objects
9.2 Property descriptors
9.3 Retrieving descriptors for properties
9.4 Defining properties via descriptors
9.5
Object.create()
: Creating objects via descriptors
9.6 Use cases for
Object.getOwnPropertyDescriptors()
9.7 Omitting descriptor properties
9.8 What property attributes do built-in constructs use?
9.9 API: property descriptors
9.10 Further reading
10 Protecting objects from being changed
10.1 Levels of protection: preventing extensions, sealing, freezing
10.2 Preventing extensions of objects
10.3 Sealing objects
10.4 Freezing objects
10.5 Further reading
11 Properties: assignment vs. definition
11.1 Assignment vs. definition
11.2 Assignment and definition in theory (optional)
11.3 Definition and assignment in practice
11.4 Which language constructs use definition, which assignment?
11.5 Further reading and sources of this chapter
12 Enumerability of properties
12.1 How enumerability affects property-iterating constructs
12.2 The enumerability of pre-defined and created properties
12.3 Use cases for enumerability
12.4 Conclusion
V OOP: techniques
13 Techniques for instantiating classes
13.1 The problem: initializing a property asynchronously
13.2 Solution: Promise-based constructor
13.3 Solution: static factory method
13.4 Subclassing a Promise-based constructor (optional)
13.5 Conclusion
13.6 Further reading
14 Copying instances of classes:
.clone()
vs. copy constructors
14.1
.clone()
methods
14.2 Static factory methods
14.3 Acknowledgements
15 Immutable wrappers for collections
15.1 Wrapping objects
15.2 An immutable wrapper for Maps
15.3 An immutable wrapper for Arrays
VI Regular expressions
16 Regular expressions: lookaround assertions by example
16.1 Cheat sheet: lookaround assertions
16.2 Warnings for this chapter
16.3 Example: Specifying what comes before or after a match (positive lookaround)
16.4 Example: Specifying what does not come before or after a match (negative lookaround)
16.5 Interlude: pointing lookaround assertions inward
16.6 Example: match strings not starting with
'abc'
16.7 Example: match substrings that do not contain
'.mjs'
16.8 Example: skipping lines with comments
16.9 Example: smart quotes
16.10 Acknowledgements
16.11 Further reading
VII Miscellaneous topics
17 Exploring Promises by implementing them
17.1 Refresher: states of Promises
17.2 Version 1: Stand-alone Promise
17.3 Version 2: Chaining
.then()
calls
17.4 Convenience method
.catch()
17.5 Omitting reactions
17.6 The implementation
17.7 Version 3: Flattening Promises returned from
.then()
callbacks
17.8 Version 4: Exceptions thrown in reaction callbacks
17.9 Version 5: Revealing constructor pattern
18 Metaprogramming with Proxies
18.1 Overview
18.2 Programming versus metaprogramming
18.3 Proxies explained
18.4 Use cases for Proxies
18.5 The design of the Proxy API
18.6 FAQ: Proxies
18.7 Reference: the Proxy API
18.8 Conclusion
18.9 Further reading
19 Where are the remaining chapters?