| |
| |
Foreword | |
| |
| |
| |
Foreword | |
| |
| |
| |
Preface | |
| |
| |
| |
Introducing Functional JavaScript | |
| |
| |
The Case for JavaScript | |
| |
| |
Some Limitations of JavaScript | |
| |
| |
Getting Started with Functional Programming | |
| |
| |
Why Functional Programming Matters | |
| |
| |
Functions as Units of Abstraction | |
| |
| |
Encapsulation and Hiding | |
| |
| |
Functions as Units of Behavior | |
| |
| |
Data as Abstraction | |
| |
| |
A Taste of Functional JavaScript | |
| |
| |
On Speed | |
| |
| |
The Case for Underscore | |
| |
| |
Summary | |
| |
| |
| |
First-Class Functions and Applicative Programming | |
| |
| |
Functions as First-Class Things | |
| |
| |
JavaScript's Multiple Paradigms | |
| |
| |
Applicative Programming | |
| |
| |
Collection-Centric Programming | |
| |
| |
Other Examples of Applicative Programming | |
| |
| |
Defining a Few Applicative Functions | |
| |
| |
Data Thinking | |
| |
| |
"Table-Like" Data | |
| |
| |
| |
Variable Scope and Closures | |
| |
| |
Global Scope | |
| |
| |
Lexical Scope | |
| |
| |
Dynamic Scope | |
| |
| |
JavaScript's Dynamic Scope | |
| |
| |
Function Scope | |
| |
| |
Closures | |
| |
| |
Simulating Closures | |
| |
| |
Using Closures | |
| |
| |
Closures as an Abstraction | |
| |
| |
Summary | |
| |
| |
| |
Higher-Order Functions | |
| |
| |
Functions That Take Other Functions | |
| |
| |
Thinking About Passing Functions: max, finder, and best | |
| |
| |
More Thinking About Passing Functions: repeat, repeatedly, and iterateUntil | |
| |
| |
Functions That Return Other Functions | |
| |
| |
Capturing Arguments to Higher-Order Functions | |
| |
| |
Capturing Variables for Great Good | |
| |
| |
A Function to Guard Against Nonexistence: mull | |
| |
| |
Putting It All Together: Object Validators | |
| |
| |
Summary | |
| |
| |
| |
Function-Building Functions | |
| |
| |
The Essence of Functional Composition | |
| |
| |
Mutation Is a Low-Level Operation | |
| |
| |
Currying | |
| |
| |
To Curry Right, or To Curry Left | |
| |
| |
Automatically Currying Parameters | |
| |
| |
Currying for Fluent APIs | |
| |
| |
The Disadvantages of Currying in JavaScript | |
| |
| |
Partial Application | |
| |
| |
Partially Applying One and Two Known Arguments | |
| |
| |
Partially Applying an Arbitrary Number of Arguments | |
| |
| |
Partial Application in Action: Preconditions | |
| |
| |
Stitching Functions End-to-End with Compose | |
| |
| |
Pre- and Postconditions Using Composition | |
| |
| |
Summary | |
| |
| |
| |
Recursion | |
| |
| |
Self-Absorbed Functions (Functions That Call Themselves) | |
| |
| |
Graph Walking with Recursion | |
| |
| |
Depth-First Self-Recursive Search with Memory | |
| |
| |
Recursion and Composing Functions: Conjoin and Disjoin | |
| |
| |
Codependent Functions (Functions Calling Other Functions That Call Back) | |
| |
| |
Deep Cloning with Recursion | |
| |
| |
Walking Nested Arrays | |
| |
| |
Too Much Recursion! | |
| |
| |
Generators | |
| |
| |
The Trampoline Principle and Callbacks | |
| |
| |
Recursion Is a Low-Level Operation | |
| |
| |
Summary | |
| |
| |
| |
Purity, Immutability, and Policies for Change | |
| |
| |
Purity | |
| |
| |
The Relationship Between Purity and Testing | |
| |
| |
Separating the Pure from the Impure | |
| |
| |
Property-Testing Impure Functions | |
| |
| |
Purity and the Relationship to Referential Transparency | |
| |
| |
Purity and the Relationship to Idempotence | |
| |
| |
Immutability | |
| |
| |
If a Tree Falls in the Woods, Does It Make a Sound? | |
| |
| |
Immutability and the Relationship to Recursion | |
| |
| |
Defensive Freezing and Cloning | |
| |
| |
Observing Immutability at the Function Level | |
| |
| |
Observing Immutability in Objects | |
| |
| |
Objects Are Often a Low-Level Operation | |
| |
| |
Policies for Controlling Change | |
| |
| |
Summary | |
| |
| |
| |
Flow-Based Programming | |
| |
| |
Chaining | |
| |
| |
A Lazy Chain | |
| |
| |
Promises | |
| |
| |
Pipelining | |
| |
| |
Data Flow versus Control Flow | |
| |
| |
Finding a Common Shape | |
| |
| |
A Function to Simplify Action Creation | |
| |
| |
Summary | |
| |
| |
| |
Programming Without Class | |
| |
| |
Data Orientation | |
| |
| |
Building Toward Functions | |
| |
| |
Mixins | |
| |
| |
Core Prototype Munging | |
| |
| |
Class Hierarchies | |
| |
| |
Changing Hierarchies | |
| |
| |
Flattening the Hierarchy with Mixins | |
| |
| |
New Semantics via Mixin Extension | |
| |
| |
New Types via Mixin Mixing | |
| |
| |
Methods Are Low-Level Operations | |
| |
| |
}).call("Finis�); | |
| |
| |
| |
Functional JavaScript in the Wild | |
| |
| |
| |
Annotated Bibliography | |
| |
| |
Index | |