𝔖 Scriptorium
✦   LIBER   ✦

📁

Beginning Functional JavaScript: Uncover the Concepts of Functional Programming with EcmaScript 8

✍ Scribed by Anto Aravinth


Publisher
Apress
Year
2018
Tongue
English
Leaves
320
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Understand functional programming concepts and the functional nature of the JavaScript language. Starting with an introduction to functional programming concepts, you will learn the key differences between imperative and functional programming. Diving straight into JavaScript functions, you will learn to write them with ES8. Followed by this you will move to higher order functions and learn how 'Function as Data' opens up a world of possibilities.

You will then build higher order functions with closures. Arrays will then be introduced, followed by a set of APIs you can use with them. You will learn how to transform one function to another using currying and partial application. The compose function will be discussed in detail, followed by functors and monads. After having an in-depth look at applicative functors, you will learn the new features offered in ES8.

The concluding chapters of Beginning Functional JavaScript will show you how to use a functional toolkit to build a small library that allows you to develop web applications, followed by tips on testing your functional code.

What You Will Learn

  • Discover functional programming concepts such as string padding and async functions
  • Identify how functions are treated in JavaScript
  • Create a functional library that mimics Underscore.JS
  • Deep dive into ES8 functional features such as spread operators and generators
  • Create a library that works like the react-redux pattern by following the functional paradigm

Who This Book Is For

Novice JavaScript developers.


✦ Table of Contents


Table of Contents
About the Authors
About the Technical Reviewer
Acknowledgments
Introduction
Chapter 1: Functional Programming in Simple Terms
What Is Functional Programming? Why Does It Matter?
Referential Transparency
Imperative, Declarative, Abstraction
Functional Programming Benefits
Pure Functions
Pure Functions Lead to Testable Code
Reasonable Code
Parallel Code
Cachable
Pipelines and Composable
A Pure Function Is a Mathematical Function
What We Are Going to Build
Is JavaScript a Functional Programming Language?
Summary
Chapter 2: Fundamentals of JavaScript Functions
ECMAScript: A Bit of History
Creating and Executing Functions
First Function
Strict Mode
Return Statement Is Optional
Multiple Statement Functions
Function Arguments
ES5 Functions Are Valid in ES6 and Above
Setting Up Our Project
Initial Setup
Our First Functional Approach to the Loop Problem
Gist on Exports
Gist on Imports
Running the Code Using Babel-Node
Creating Script in Npm
Running the Source Code from Git
Summary
Chapter 3: Higher Order Functions
Understanding Data
Understanding JavaScript Data Types
Storing a Function
Passing a Function
Returning a Function
Abstraction and Higher Order Functions
Abstraction Definitions
Abstraction via Higher Order Functions
Higher Order Functions in the Real World
every Function
some Function
sort Function
Summary
Chapter 4: Closures and Higher Order Functions
Understanding Closures
What Are Closures?
Remembering Where It Is Born
Revisiting sortBy Function
Higher Order Functions in the Real World (Continued)
tap Function
unary Function
once Function
memoize Function
assign function
Summary
Chapter 5: Being Functional on Arrays
Working Functionally on Arrays
map
filter
Chaining Operations
concatAll
Reducing Function
reduce Function
Zipping Arrays
zip Function
Summary
Chapter 6: Currying and Partial Application
A Few Notes on Terminology
Unary Function
Binary Function
Variadic Functions
Currying
Currying Use Cases
A logger Function: Using Currying
Revisit Curry
Back to logger Function
Currying in Action
Finding a Number in Array Contents
Squaring an Array
Data Flow
Partial Application
Implementing partial Function
Currying vs. Partial Application
Summary
Chapter 7: Composition and Pipelines
Composition in General Terms
Unix Philosophy
Functional Composition
Revisiting map,filter
compose Function
Playing with the compose Function
curry and partial to the Rescue
compose Many Functions
Pipelines and Sequence
Implementing pipe
Odds on Composition
Composition Is Associative
The Pipeline Operator
Debugging Using the tap Function
Summary
Chapter 8: Fun with Functors
What Is a Functor?
Functor Is a Container
Implementing map
MayBe
Implementing MayBe
Simple Use Cases
Real-World Use Cases
Either Functor
Implementing Either
Reddit Example Either Version
Word of Caution: Pointed Functor
Summary
Chapter 9: Monads in Depth
Getting Reddit Comments for Our Search Query
The Problem
Implementation of the First Step
Merging Reddit Calls
Problem of Nested/Many maps
Solving the Problem via join
join Implementation
chain Implementation
What Is a Monad?
Summary
Chapter 10: Pause, Resume, and Async with Generators
Async Code and Its Problem
Callback Hell
Generators 101
Creating Generators
Caveats of Generators
yield Keyword
done Property of Generator
Passing Data to Generators
Using Generators to Handle Async Calls
Generators for Async: A Simple Case
Generators for Async: A Real-World Case
Async Functions in ECMAScript 2017
Promise
Await
Async
Chaining Callbacks
Error Handling in Async Calls
Async Functions Transpiled to Generators
Summary
Chapter 11: Building a React-Like Library
Immutability
Building a Simple Redux Library
Building a Framework Like HyperApp
Virtual DOM
JSX
JS Fiddle
CreateActions
Render
Patch
Update
Merge
Remove
Summary
Chapter 12: Testing and Closing Thoughts
Introduction
Types of Testing
BDD and TDD
JavaScript Test Frameworks
Testing Using Mocha
Installation
Simple Mocha Test
Tests for Currying, Monads, and Functors
Testing Functional Library
Async Tests with Mocha
Mocking Using Sinon
Testing with Jasmine
Code Coverage
Linting
Unit Testing Library Code
Closing Thoughts
Summary
Correction to: Fun with Functors
Index


📜 SIMILAR VOLUMES


Beginning Functional JavaScript: Uncover
✍ Anto Aravinth, Srikanth Machiraju 📂 Library 📅 2018 🏛 Apress 🌐 English

Understand functional programming concepts and the functional nature of the JavaScript language. Starting with an introduction to functional programming concepts, you will learn the key differences between imperative and functional programming. Diving straight into JavaScript functions, you will lea

Beginning Functional JavaScript: Uncover
✍ Srikanth Machiraju & Anto Aravinth [Srikanth Machiraju] 📂 Library 📅 2018 🏛 Apress 🌐 English

<span><p>Understand functional programming concepts and the functional nature of the JavaScript language. Starting with an introduction to functional programming concepts, you will learn the key differences between imperative and functional programming. Diving straight into JavaScript functions, you

Beginning Functional JavaScript: Functio
✍ Anto Aravinth [Anto Aravinth] 📂 Library 📅 2017 🏛 Apress 🌐 English

<span><span><p>Learn functional programming concepts using JavaScript ES6. You will learn concepts such as currying, partial functions, higher-order functions, and monads.</p><p>Programming languages have evolved from focusing on procedures to objects and now on function. JavaScript<i> </i>supports

Beginning Functional JavaScript: Functio
✍ Anto Aravinth [Anto Aravinth] 📂 Library 📅 2017 🏛 Apress 🌐 English

<span><span><p>Learn functional programming concepts using JavaScript ES6. You will learn concepts such as currying, partial functions, higher-order functions, and monads.</p><p>Programming languages have evolved from focusing on procedures to objects and now on function. JavaScript<i> </i>supports