Skip to Content
View all events

JavaScript the Hard Parts: Closures

Published by Pearson

Advanced content levelAdvanced

Understand under-the-hood closure - one of JavaScript’s most powerful yet misunderstood concepts - to write cleaner more professional code

In JavaScript the Hard Parts you balance developing ‘under-the-hood' mental models of how the challenging concept works with diving into coding challenges – giving you the capacity to effortlessly navigate through any new problems.

We will cover the core functional programming concept of closure – probably the most misunderstood feature of JavaScript yet one of the most powerful. By introducing the execution context and variable environment, we'll be able to understand classic closure functions like once, memoize and even password-protected functions.

We’ll also be in a position to take advantage of the new ES6 feature including iterators and to better understand how state persists in our asynchronous code

We will also be better able to understand one of the most popular JavaScript design patterns - the module pattern

What you’ll learn and how you can apply it

  • Understand how one of the most misunderstood but most powerful features of JavaScript – closure – works under-the-hood
  • Understand core JS runtime features - execution context, JavaScript execution model and the variable environment
  • Be able to wield, optimize and debug popular pro utility functions like once and memoize
  • Be able to implement the module pattern - one of the cleanest and most resilient design patterns in JavaScript

This live event is for you because...

  • JavaScript the Hard Parts is designed to build an understanding of complex concepts from first principles to benefit both newer and more experienced developers
  • Software engineers working with JavaScript in their work who use closure but don’t understand how it works under-the-hood and therefore cannot use it to its maximum effectiveness
  • Software engineers interested in writing cleaner professional code with helper functions like once, memoize and the module design pattern

Prerequisites

Course Set-up:

  • URL for challenges will be csbin.io/closures

Recommended Preparation:

Learning JavaScript: A Hands-On Guide to the Fundamentals of Modern JavaScript - Closure section (book)

Recommended Follow-up:

Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript (book)

Schedule

The time frames are only estimates and may vary according to how the class is progressing.

JavaScript core execution model

  • Topics covered: Thread of execution, variable environment, execution context, call stack (15 mins)
  • Q&A (5 mins)

Higher order functions

  • Returning a function from a function (confuses even seasoned devs) (15 mins)
  • Q&A (5 mins)
  • Pair programming (20 mins)

Lexical scope (15 mins)

  • How can we test whether JavaScript is statically or dynamically scoped?

Closure and persistent lexical scope (the ‘backpack’)

  • The intuitions of the ‘backpack’ or closure (40 mins)
  • Q&A (15 mins)

Using closure in helper functions, iterators and async

  • Once, memoize (10 mins)
  • Q&A (5 mins)
  • Pair programming (20 mins)

Your Instructor

  • William Sentance

    Will Sentance leads Codesmith - a software engineering and machine learning school in Los Angeles, New York and at Oxford University. Before Codesmith he started Icecomm - a realtime video platform for developers and worked as a software engineer at Gem - a blockchain startup. He completed his academic work at Oxford and Harvard. He has given talks on coding and entrepreneurship at Pivotal Labs, Harvard, Yale, USC, UCLA and Frontend Masters.

    linkedinXlinksearch

Skill covered

JavaScript