Functional JavaScript First Steps, v2

Anjana Vakil
Software Engineer & Educator
3 hours, 27 minutes CC
Functional JavaScript First Steps, v2

Course Description

A friendly, practical introduction to functional programming fundamentals in JavaScript. Learn the power of the pure function while exploring functional programming paradigms. Compare iterative and recursive code and create more complex programs with higher-order functions and functional composition. Free yourself from mutations and write more reliable and predictable code with functional programming!

This course and others like it are available as part of our Frontend Masters video subscription.

Preview
Close

Course Details

Published: February 14, 2025

Learn Straight from the Experts Who Shape the Modern Web

Your Path to Senior Developer and Beyond
  • 200+ In-depth courses
  • 18 Learning Paths
  • Industry Leading Experts
  • Live Interactive Workshops

Table of Contents

Introduction

Section Duration: 22 minutes
  • Introduction
    Anjana Vakil begins the course with an outline of the functional programming topics that will be discussed. The notes and exercises for the course are available in the browser. A repo is provided to allow the exercises to be completed locally.
  • What is Functional Programming
    Anjana shares some of the terms associated with functional programming, like higher-order, monoid, and functor. These terms can be confusing to developers new to functional programming. Along with functional programming, other programming styles exist, like imperative, declarative, and object-oriented. This course aims to outline the differences between these styles and dive into the functional programming concepts.

Programming with Pure Functions

Section Duration: 30 minutes

Recursion

Section Duration: 43 minutes

Higher-Order Functions

Section Duration: 33 minutes
  • Higher-Order Functions
    Anjana introduces higher-order functions, which take one or more functions as arguments. Examples of higher-order functions are the array methods filter, map, and reduce. These methods accept a function as an argument, and that function performs an operation on each value in an array. For example, the predicate function passed to the filter will return true or false for whether an item in the array should be included in the filtered results.
  • Implement Filter Function Exercise
    Students are instructed to implement a filter function that filters values out of an array. Utility methods for concatenating arrays and returning the length, head, and tail are provided. Recursion should be used rather than iteration.
  • Implement Map Function Exercise
    Students are instructed to implement the map function. This function transforms an array by passing each element to a function passed as an argument. This recursive operation continually calls map while concatenating the head of the array with each subsequent recursive call.
  • Implement Reduce Function Exercise
    Anjana explains the functional implementation of the reduce function. Students are then instructed to implement reducer functions for sum and max operations.

Scope & Closure

Section Duration: 16 minutes
  • Closure Overview
    Anjana introduces closure, which is the combination of a function bundled together with references to its surrounding scope. Closures are created every time a function is created, and the function "remembers" its outer scope. This lesson also explains additional terms like partially applied functions and currying.
  • Higher-Order Functions with Closure Exercise
    Students are instructed to create higher-order functions that close over the diamondPattern function. These higher-order functions will "lock in" values with closure to create more specific SVG-generating functions.

Function Composition

Section Duration: 21 minutes

Immutability

Section Duration: 30 minutes

Wrapping Up

Section Duration: 7 minutes
  • Wrapping Up
    Anjana wraps up the course by asking students to share thoughts about functional-style programming. Additional resources are provided and students are encouraged to explore other functional languages.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Start a 7-Day Free Trial