Hard Parts: Functional JS Foundations
Table of Contents
IntroductionWill 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 & ConceptsWill 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.
Higher Order Functions
The Problem: Repetitive FunctionsWill 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 FunctionsWill 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 ReviewWill 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 ProgrammingWill describes the pair programming set of challenges that the audience is encouraged to work through.
Arrow & Anonymous FunctionsWill 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
Reduce IntroductionWill 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 ExampleWill 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 MethodsWill explains that arrays have access to methods, and explains where these methods are stored.
FilterWill explains how the filter method executes under the hood.
Chaining Array MethodsWill 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.
Function CompositionWill 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 ReduceWill 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 ReviewWill 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 FunctionsWill explains what function purity is, defines side effects, and how they can threaten function purity.
ImmutabilityWill defines immutability as not mutating any data where it is past by reference, and goes over an example.
Pure Functions & Immutability ReviewWill 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.
ClosureWill demonstrates how closure allows the storing of a function's memory by executing that given function within another function.
Closure Under the HoodWill covers in this section what happens within an execution context and memory when closure is used in functional programming.
Inner FunctionWill explains how data is processed within the inner function, and shows that the return value can be assigned to a global variable.
Outer FunctionWill 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.
Function Decoration & Partial Application
Function Decoration IntroductionWill 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 FunctionWill demonstrates what function decoration, or higher order function is, and how it runs.
Invoking a Decorated FunctionWill demonstrates the effect of a function decoration on the existing function, multiplyBy2.
Function Decoration ReviewWill summarizes the example of function decoration he went through in the previous section.
Partial Application IntroductionWill explains how to avoid an arity mismatch, by decorating a function and pre-filling one of its inputs.
Partial Application ExampleWill 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 ClarificationsWill 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 ReviewWill reviews partial application and its benefits, namely, easier to add features, readability and simplify the debugging process.