Why learn closure when I could be learning Node or React?

Shouldn’t I be spending my time with understanding frameworks - they’re what I actually do on the job 👩🏽‍💻 Why should I learn closure in JavaScript??

We give talks to some of the most sophisticated engineering teams in the country. We see people trying to understand concepts like Node and the module pattern while implementing memoization and debugging asynchronicity.

But without closure, their understanding of these concepts was always limited.

Becoming a developer who has mastery over their tools requires understanding what’s going on under-the-hood. 

Learning new topics is about combining existing units of knowledge in new and often complex ways. If you’re missing one of the core units of knowledge you cannot build up to more complex concepts. You have to ‘hand wave’ the way professors would at college when they say “It should be clear at this point”.

True mastery means understanding the core principles and building up from them. That being said, being a developer is about having to make things work without understanding everything.

They call it choosing your ‘level of abstraction’. You cannot understand everything down to the silicon.

But that’s not the purpose of this course. The purpose of this course is for you take time out of ‘making it work to meet deadlines’ to truly understand a concept that will allow you to accelerate all your future engineering.

Every time you understand something deeply it’s an investment for the future! It’s like building a system that’s more flexible and ready to scale. It’ll take time but it will pay off in the rest of your engineering ⏱.

Closure is that building block that all the other concepts sit upon. 4 of the most important areas of modern programming rest on it:

⭐️Professional-grade functions like memoize and once to write cleaner and more efficient code 

⭐️Design patterns like Node’s module pattern (the CommonJS pattern)

⭐️Functional programming techniques like partial application, currying and monads

⭐️Asynchronous JavaScript and the callback pattern

So how should I learn this?

In college we would always sit in lectures and tune out thinking we would figure it out for ourselves later. That’s fair - you have to take the knowledge you’re presented and make it your own by going through challenges and building your own mental models

BUT - what if we had been made to engage in the talks by being called on, we could have got so much more out of it - we’re going to take that approach in this course.

Will and I have taught 100s of workshops between us and whenever we were trying to explain these complex concepts we were drawn to take a pen and try to diagram it out. 

That’s what we’re going to do in this course - visualize every line of code as it runs.

There are no mysteries in programming if you don’t skip steps!

We’re going to develop a mental model of closure that’s intuitive but built from scratch

If you have 10 years of experience it’ll join the dots behind the scenes of many of the concepts you use daily.

If you’re newer to programming, it’ll give you the foundations to accelerate your understanding of JavaScript, React and Node.

It’s not a bad thing either that one of Google’s favorite interview questions is ‘What is closure’ - this is the concept that can truly test your understanding of the language.

You will follow along with four other developers as we lead them through the code and as they hit blocks, ask questions and have them resolved (in something like the socratic method).

By the end of this course you will:

⭐️Have a mature understanding of JavaScript

⭐️Improve your technical communication

⭐️Have a set of professional techniques for writing more maintainable code

What's included?

7 units from basic to advanced

Principles of JavaScript

Unit 1

  • 📽4 video lessons | 🕐25 mins

    In this first module we will get an overview of closure before digging into how JavaScript actually runs our code.

    We will cover the 3 major parts of synchronous JavaScript code execution - the thread of execution, memory (or variable environment) and execution contexts. This will ensure that when the hard parts follow, we have all the foundations to understand them effortlessly .

Closure & returning functions

Unit 2

  • 📽3 video lessons | 🕐20 mins

    JavaScript functions are first-class objects - a core feature of JavaScript’s flexible functional nature. We may have heard this said before but do we really understand intuitively and precisely? Doing so is vital to understanding closure and all the concepts (from Node to functional programming techniques) that rest upon it.

    We’ll touch on the role of the heap in JavaScript memory allocation and the flexibility this gives us to assign, reassign and return functions.

Closure in JavaScript

Unit 3

  • 📽3 video lessons | 🕐30 mins

    Functions in JavaScript should have their memories automatically garbage collected after each invocation - that’s one of the best features of a higher level language. But what if we want a function to remember details of its previous invocation?

    Here we take all the first principles of JavaScript execution and combine them together at last to enable our JavaScript functions (for the first time) to persist their memory between executions in a ‘backpack’. It’s going to change how we write code for good.

Lexical scoping & pro closure

Unit 4

  • 📽7 video lessons | 🕐65 mins

    Now we go deep under-the-hood of closure. We explore the manner by which our functions maintain a reference to their lexical scope through a hidden [[scope]] property. We see how state is persisted privately and learn terms like the Closed over variable environment and persistent lexical scope referenced data.

    We then relate closure to such core professional JavaScript concepts as memoization, the module pattern, iterators & generators and persisting state in an asynchronous execution environment.

Utility functions: Once

Unit 5

  • Diagramming Section - Chapters: 1-4, Length: ~20 mins

    Building applications often requires restricting how code can execute - including limiting code to execute just once.

    Conventional functions couldn’t remember that they’ve previously been run (without global state - which would be super unmaintainable). In this module we develop an understanding of how to use our functions’ persistent memories to elegantly restrict their execution.

Utility functions: Memoization

Unit 6

  • 📽2 video lessons | 🕐35 mins

    Performance matters but sometimes we have to run code that’s slow - say parsing text or computing something mathematical. Doing so once is necessary, doing so twice is not.

    We’ll see in this unit how we can use closure to effortlessly increase performance of our applications and ensure no redundant recalculations by persisting previous work using our closure techniques.

Module design pattern

Unit 7

  • 📽1 video lesson | 🕐25 mins

    Monolithic applications are hard to maintain. Node and the CommonJS pattern let us modularize our code to preserve pseudo-global namespaces on a file-by-file basis. In this unit we explore how to effectively modularize your JavaScript code and protect state using closure.

Interview: Olivier De Meulder

Author of #1 most popular closure article on Medium

  • 📽1 video interview

    Olivier is an Engineering Manager working on subscriptions and payments platforms and a former entrepreneur. He is the author of the most popular article on closure: "I never understood JavaScript closures - Until someone explained it to me like this"

Meet Your Instructors

  • Phillip Troutman

    Lead Instructor at Codesmith

    Phillip Troutman

    Phillip Troutman is a Senior Fullstack Engineer and Lead Instructor at Codesmith NYC - an immersive software engineering residency. Phil is a prominent invited guest speaker and instructor in the developer community. Prior to Codesmith, Phillip specialized in security system design patterns for hardware and software for the Department of Homeland Security. While Phillip is passionate about all aspects of web development he has shown a particular leadership in improvements to React.
  • William  Sentance

    Co-Founder & CEO of Codesmith

    William Sentance

    Will Sentance is co-founder and CEO at Codesmith – a software engineering and machine learning residency based in Los Angeles, New York, and Oxford. He is the creator of Icecomm, the most famous developer platform for P2P video and data communication. Before Codesmith, Will was CEO at Ownly and a Software Engineer at Gem. Will graduated from Oxford University and Harvard University.

Pick your path

Each learning path is a one-time purchase and always available to reference

Learn JavaScript Closures Scholarship

We want Learn JavaScript Closures to be accessible to all and have developed an application based scholarship process to receive this course for free. You can complete the application here


  • What if I don't like the course?

    We have a money back guarantee. Shoot us an email at hello@codesmith.io with why the course didn't work out for you and we'll refund you as soon as we can.

  • Is this the same as the free workshop taught at Codesmith - JavaScript the Hard Parts: Closure?

    This course builds on the Hard Parts closure course but goes into significantly more depth especially around once, memoization and the module pattern.

  • What level should I be at to take this course?

    The course is designed to take your from first principles up to advanced implementations and so can work for engineers from beginner to expert level.

Start mastering closures and be ready to understand even the most complex JavaScript application

Get started now