2min chapter

Syntax - Tasty Web Development Treats cover image

Stump’d × JavaScript × GraphQL × Memory Safety × Web History

Syntax - Tasty Web Development Treats

CHAPTER

Closure in JavaScript

A closure is a function that returns a function with its own scope. In TypeScript, it's able to access the outer scope of the parent function so that you can sort of carry around data by calling that function over and over again. The big example is always like a counter, right? You have a function called make counter, and then that returns an increment function. Every single time you run that increment function, it still has access to this invisible variable of the upper scope.

00:00

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode