Home Page Icon
Home Page
Table of Contents for
Table of Contents
Close
Table of Contents
by Dan Mantyla
Functional Programming in JavaScript
Functional Programming in JavaScript
Table of Contents
Functional Programming in JavaScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. The Powers of JavaScript's Functional Side – a Demonstration
Introduction
The demonstration
The application – an e-commerce website
Imperative methods
Functional programming
Summary
2. Fundamentals of Functional Programming
Functional programming languages
What makes a language functional?
Advantages
Cleaner code
Modularity
Reusability
Reduced coupling
Mathematically correct
Functional programming in a nonfunctional world
Is JavaScript a functional programming language?
Working with functions
Self-invoking functions and closures
Higher-order functions
Pure functions
Anonymous functions
Method chains
Recursion
Divide and conquer
Lazy evaluation
The functional programmer's toolkit
Callbacks
Array.prototype.map()
Array.prototype.filter()
Array.prototype.reduce()
Honorable mentions
Array.prototype.forEach
Array.prototype.concat
Array.prototype.reverse
Array.prototype.sort
Array.prototype.every and Array.prototype.some
Summary
3. Setting Up the Functional Programming Environment
Introduction
Functional libraries for JavaScript
Underscore.js
Fantasy Land
Bilby.js
Lazy.js
Bacon.js
Honorable mentions
Development and production environments
Browsers
Server-side JavaScript
A functional use case in the server-side environment
CLI
Using functional libraries with other JavaScript modules
Functional languages that compile into JavaScript
Summary
4. Implementing Functional Programming Techniques in JavaScript
Partial function application and currying
Function manipulation
Apply, call, and the this keyword
Binding arguments
Function factories
Partial application
Partial application from the left
Partial application from the right
Currying
Function composition
Compose
Sequence – compose in reverse
Compositions versus chains
Programming with compose
Mostly functional programming
Handling events
Functional reactive programming
Reactivity
Putting it all together
Summary
5. Category Theory
Category theory
Category theory in a nutshell
Type safety
Object identities
Functors
Creating functors
Arrays and functors
Function compositions, revisited
Monads
Maybes
Promises
Lenses
jQuery is a monad
Implementing categories
Summary
6. Advanced Topics and Pitfalls in JavaScript
Recursion
Tail recursion
The Tail-call elimination
Trampolining
The Y-combinator
Memoization
Variable scope
Scope resolutions
Global scope
Local scope
Object properties
Closures
Gotchas
Function declarations versus function expressions versus the function constructor
Function declarations
Function expressions
The function constructor
Unpredictable behavior
Summary
7. Functional and Object-oriented Programming in JavaScript
JavaScript – the multi-paradigm language
JavaScript's object-oriented implementation – using prototypes
Inheritance
JavaScript's prototype chain
Inheritance in JavaScript and the Object.create() method
Mixing functional and object-oriented programming in JavaScript
Functional inheritance
Strategy Pattern
Mixins
Classical mixins
Functional mixins
Summary
A. Common Functions for Functional Programming in JavaScript
B. Glossary of Terms
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Cover
Next
Next Chapter
Functional Programming in JavaScript
Table of Contents
Functional Programming in JavaScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. The Powers of JavaScript's Functional Side – a Demonstration
Introduction
The demonstration
The application – an e-commerce website
Imperative methods
Functional programming
Summary
2. Fundamentals of Functional Programming
Functional programming languages
What makes a language functional?
Advantages
Cleaner code
Modularity
Reusability
Reduced coupling
Mathematically correct
Functional programming in a nonfunctional world
Is JavaScript a functional programming language?
Working with functions
Self-invoking functions and closures
Higher-order functions
Pure functions
Anonymous functions
Method chains
Recursion
Divide and conquer
Lazy evaluation
The functional programmer's toolkit
Callbacks
Array.prototype.map()
Array.prototype.filter()
Array.prototype.reduce()
Honorable mentions
Array.prototype.forEach
Array.prototype.concat
Array.prototype.reverse
Array.prototype.sort
Array.prototype.every and Array.prototype.some
Summary
3. Setting Up the Functional Programming Environment
Introduction
Functional libraries for JavaScript
Underscore.js
Fantasy Land
Bilby.js
Lazy.js
Bacon.js
Honorable mentions
Development and production environments
Browsers
Server-side JavaScript
A functional use case in the server-side environment
CLI
Using functional libraries with other JavaScript modules
Functional languages that compile into JavaScript
Summary
4. Implementing Functional Programming Techniques in JavaScript
Partial function application and currying
Function manipulation
Apply, call, and the this keyword
Binding arguments
Function factories
Partial application
Partial application from the left
Partial application from the right
Currying
Function composition
Compose
Sequence – compose in reverse
Compositions versus chains
Programming with compose
Mostly functional programming
Handling events
Functional reactive programming
Reactivity
Putting it all together
Summary
5. Category Theory
Category theory
Category theory in a nutshell
Type safety
Object identities
Functors
Creating functors
Arrays and functors
Function compositions, revisited
Monads
Maybes
Promises
Lenses
jQuery is a monad
Implementing categories
Summary
6. Advanced Topics and Pitfalls in JavaScript
Recursion
Tail recursion
The Tail-call elimination
Trampolining
The Y-combinator
Memoization
Variable scope
Scope resolutions
Global scope
Local scope
Object properties
Closures
Gotchas
Function declarations versus function expressions versus the function constructor
Function declarations
Function expressions
The function constructor
Unpredictable behavior
Summary
7. Functional and Object-oriented Programming in JavaScript
JavaScript – the multi-paradigm language
JavaScript's object-oriented implementation – using prototypes
Inheritance
JavaScript's prototype chain
Inheritance in JavaScript and the Object.create() method
Mixing functional and object-oriented programming in JavaScript
Functional inheritance
Strategy Pattern
Mixins
Classical mixins
Functional mixins
Summary
A. Common Functions for Functional Programming in JavaScript
B. Glossary of Terms
Index
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset