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 JavaScript Functions!
You have completed JavaScript Functions!
Preview
JavaScript provides separate "scopes" for each function. Any variables created within a function are not accessible outside the function, and cannot interact variables created in another function.
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
utility functions that other developers
wrote in your websites and apps.
0:00
So it's possible, even likely that
within a function is a variable that
0:03
uses the same name as a variable
used elsewhere in your script.
0:08
For example, you might write a script
with a variable named "width", but
0:12
also have a function called `computeArea`
that has a "width" variable inside it.
0:16
Two different variables
with the same name,
0:20
what does JavaScript do in this case?
0:23
Fortunately, JavaScript provides separate
scopes for each function, that is,
0:25
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