
The Hard Parts of Functional JavaScript
Learning Paths:
Topics:
Table of Contents
Introduction
Introduction
Will Sentence introduces himself, explains what parts of functional programming he will cover in this course, and why functional programming can be useful in the everyday life of a programmer.Functional Programming Benefits & Concepts
Will briefly explains the different concepts of functional programming that will be explored in depth during the course. The advantages of functional programming are also discussed.
JavaScript Principles Review
Executing JavaScript Code: A Review
Will explains what happens when a function is executed by going over what is stored in memory, what an execution context is, and what is an output.Call Stack Review
Will describes what happens when a function finishes running, JavaScript needs to keep track of it, and uses a call stack for that.Functions Review
Will reviews how two different functions are executed in detail. The audience is asked to describe in great technical detail how a function executes in JavaScript, and have solid foundations for the rest of the class.
Higher Order Functions
The Problem: Repetitive Functions
Will demonstrates how to use placeholders as a function's argument and how this allows developers to apply the Don't Repeat Yourself (DRY) principle.Generalizing Functions
Will demonstrates how to use a generalized function and how to pass, as a parameter, specific instructions in the form of another function.Higher-Order Functions Review
Will explains that functions are first class objects, meaning, functions can be passed as inputs of functions, and describes the difference between callback functions and higher-order functions.Higher-Order Functions Pair Programming
Will describes the pair programming set of challenges that the audience is encouraged to work through.Arrow & Anonymous Functions
Will describes how to write anonymous functions, how to write a function using an arrow, and cautions about the thinking that writing anonymous functions improves code readability.
Map & Reduce
Map
Will describes map as one of the most important higher functions in JavaScript. Map in this case, is the name usually used for the copyArrayManipulate function that was used before.Reduce Introduction
Will introduces the built-in reduce method to the audience, explains what a reducer is, what an accumulator is, and presents the concept of reducing, i.e. going from two elements to one with the help of a reducer.Reduce Example
Will covers an example of the reduce function by explaining step by step how the function reduces two elements to one repeatedly inside its execution context. Understanding reduce, is understanding how elements are combined to get to the final results.Built-In Array Methods
Will explains that arrays have access to methods, and explains where these methods are stored.Filter
Will explains how the filter method executes under the hood.Chaining Array Methods
Will demonstrates how the high order functions used previously can be chained together to avoid using a global variable on which the rest of the code would depend.
Composition
Function Composition
Will dives into function composition, and more specifically referential transparency which means replacing the execution of a function with its output. Using reduce with other functions as parameters is also described.Function Composition with Reduce
Will demonstrates how reduce works under the hood when its parameters are three other functions, and describes what happens within the function's execution context and memory.Function Composition Review
Will reviews function composition, answers a few questions from the audience about function syntax, and function arity, and talks about the clarity gained thanks to functional programming.
Purity & Immutability
Pure Functions
Will explains what function purity is, defines side effects, and how they can threaten function purity.Immutability
Will defines immutability as not mutating any data where it is past by reference, and goes over an example.Pure Functions & Immutability Review
Will reviews function purity and immutability, describes function arity, specifically the side effects of function chaining, there could be a mismatch in the amount of arguments a function can take, and explains briefly that closure is the solution to the arity issue.
Closure
Closure
Will demonstrates how closure allows the storing of a function's memory by executing that given function within another function.Closure Under the Hood
Will covers in this section what happens within an execution context and memory when closure is used in functional programming.Closure Clarifications
Will clarifies what it means in JavaScript to pass on code from one function to the next, and how code is stored in the heap.Inner Function
Will explains how data is processed within the inner function, and shows that the return value can be assigned to a global variable.Outer Function
Will demonstrates how to assign the return value of the inner function, to an outer function, and give it a global label. On the back of the inner function comes its entire surrounding local memory.Closure Clarifications & Review
Will describes what iterators are, what Closed Over Variable Environment ( C.O.V.E) is, and the different definitions of the word closure in JavaScript.
Function Decoration & Partial Application
Function Decoration Introduction
Will demonstrates that although a function cannot be edited without it compromising its purity, function decoration as the appearance of a function being edited in its scope, but is instead creating a new function, and inserting in it the function that needs to be edited.Decorating a Function
Will demonstrates what function decoration, or higher order function is, and how it runs.Invoking a Decorated Function
Will demonstrates the effect of a function decoration on the existing function, multiplyBy2.Function Decoration Review
Will summarizes the example of function decoration he went through in the previous section.Partial Application Introduction
Will explains how to avoid an arity mismatch, by decorating a function and pre-filling one of its inputs.Partial Application Example
Will dives into an example of partial application, and demonstrates what happens in memory and in the execution context while the function is running.Partial Application Clarifications
Will clarifies what partial application is by showing how data is partially applied to a function, and compares partial application and the use of closure in the example shared previously.Partial Application Review
Will reviews partial application and its benefits, namely, easier to add features, readability and simplify the debugging process.