Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Understanding Closures in JavaScript!
You have completed Understanding Closures in JavaScript!
Preview
The closure is a powerful and useful concept in JavaScript. In this video you'll learn how to create a closure.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You can create any number of closures.
0:00
even with the same variable name
contained within each one of them.
0:03
That's because the variables
are hidden from all other functions.
0:07
Let's walk through the steps
of creating a closure now.
0:12
Open up the workspace with
this video to follow along.
0:16
Here's a simple function, doghouse.
0:19
Like any function in JavaScript,
0:24
doghouse can see variables declared
outside of itself In the global scope
0:26
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up