This is a book about JavaScript, programming, and the wonders of the digital.
https://eloquentjavascript.net
Author(s): Marijn Haverbeke
Edition: 3
Year: 2018
Language: English
Tags: javascript
Introduction
On programming
Why language matters
What is JavaScript?
Code, and what to do with it
Overview of this book
Typographic conventions
Values, Types, and Operators
Values
Numbers
Strings
Unary operators
Boolean values
Empty values
Automatic type conversion
Summary
Program Structure
Expressions and statements
Bindings
Binding names
The environment
Functions
The console.log function
Return values
Control flow
Conditional execution
while and do loops
Indenting Code
for loops
Breaking Out of a Loop
Updating bindings succinctly
Dispatching on a value with switch
Capitalization
Comments
Summary
Exercises
Functions
Defining a function
Bindings and scopes
Functions as values
Declaration notation
Arrow functions
The call stack
Optional Arguments
Closure
Recursion
Growing functions
Functions and side effects
Summary
Exercises
Data Structures: Objects and Arrays
The weresquirrel
Data sets
Properties
Methods
Objects
Mutability
The lycanthrope's log
Computing correlation
Array loops
The final analysis
Further arrayology
Strings and their properties
Rest parameters
The Math object
Destructuring
JSON
Summary
Exercises
Higher-Order Functions
Abstraction
Abstracting repetition
Higher-order functions
Script data set
Filtering arrays
Transforming with map
Summarizing with reduce
Composability
Strings and character codes
Recognizing text
Summary
Exercises
The Secret Life of Objects
Encapsulation
Methods
Prototypes
Classes
Class notation
Overriding derived properties
Maps
Polymorphism
Symbols
The iterator interface
Getters, setters, and statics
Inheritance
The instanceof operator
Summary
Exercises
Project: A Robot
Meadowfield
The task
Persistent data
Simulation
The mail truck's route
Pathfinding
Exercises
Bugs and Errors
Language
Strict mode
Types
Testing
Debugging
Error propagation
Exceptions
Cleaning up after exceptions
Selective catching
Assertions
Summary
Exercises
Regular Expressions
Creating a regular expression
Testing for matches
Sets of characters
Repeating parts of a pattern
Grouping subexpressions
Matches and groups
The Date class
Word and string boundaries
Choice patterns
The mechanics of matching
Backtracking
The replace method
Greed
Dynamically creating RegExp objects
The search method
The lastIndex property
Parsing an INI file
International characters
Summary
Exercises
Modules
Modules
Packages
Improvised modules
Evaluating data as code
CommonJS
ECMAScript modules
Building and bundling
Module design
Summary
Exercises
Asynchronous Programming
Asynchronicity
Crow tech
Callbacks
Promises
Failure
Networks are hard
Collections of promises
Network flooding
Message routing
Async functions
Generators
The event loop
Asynchronous bugs
Summary
Exercises
Project: A Programming Language
Parsing
The evaluator
Special forms
The environment
Functions
Compilation
Cheating
Exercises
JavaScript and the Browser
Networks and the Internet
The Web
HTML
HTML and JavaScript
In the sandbox
Compatibility and the browser wars
The Document Object Model
Document structure
Trees
The standard
Moving through the tree
Finding elements
Changing the document
Creating nodes
Attributes
Layout
Styling
Cascading styles
Query selectors
Positioning and animating
Summary
Exercises
Handling Events
Event handlers
Events and DOM nodes
Event objects
Propagation
Default actions
Key events
Pointer events
Scroll events
Focus events
Load event
Events and the event loop
Timers
Debouncing
Summary
Exercises
Project: A Platform Game
The game
The technology
Levels
Reading a level
Actors
Encapsulation as a burden
Drawing
Motion and collision
Actor updates
Tracking keys
Running the game
Exercises
Drawing on Canvas
SVG
The canvas element
Lines and surfaces
Paths
Curves
Drawing a pie chart
Text
Images
Transformation
Storing and clearing transformations
Back to the game
Choosing a graphics interface
Summary
Exercises
HTTP and Forms
The protocol
Browsers and HTTP
Fetch
HTTP sandboxing
Appreciating HTTP
Security and HTTPS
Form fields
Focus
Disabled fields
The form as a whole
Text fields
Checkboxes and radio buttons
Select fields
File fields
Storing data client-side
Summary
Exercises
Project: A Pixel Art Editor
Components
The state
DOM building
The canvas
The application
Drawing tools
Saving and loading
Undo history
Let's draw
Why is this so hard?
Exercises
Node.js
Background
The node command
Modules
Installing with NPM
The file system module
The HTTP module
Streams
A file server
Summary
Exercises
Project: Skill-Sharing Website
Design
Long polling
HTTP interface
The server
The client
Exercises
Exercise Hints
Program Structure
Functions
Data Structures: Objects and Arrays
Higher-Order Functions
The Secret Life of Objects
Project: A Robot
Bugs and Errors
Regular Expressions
Modules
Asynchronous Programming
Project: A Programming Language
The Document Object Model
Handling Events
Project: A Platform Game
Drawing on Canvas
HTTP and Forms
Project: A Pixel Art Editor
Node.js
Project: Skill-Sharing Website