Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Benjamin Hedgepeth
5,672 PointsScope and context in JavaScript
I've read that scope and context within JavaScript are not the same thing. While reading the topic of scope in Wikipedia, it has generated some confusion. Clarification would be appreciated.
https://en.wikipedia.org/wiki/Scope_(computer_science)
"The term "scope" is also used to refer to the set of all entities that are visible or names that are valid within a portion of the program or at a given point in a program, which is more correctly referred to as context or environment."
I've only quoted what confused me. It would probably be best if those that are familiar to go to the source itself.
1 Answer
Steven Parker
243,160 PointsThese quotes from the same article might be helpful.
Elsewhere in the article it says, "scope is a property of an identifier, and is fixed, while context is a property of a program, which varies by position."
It also says: Narrowly speaking, during execution a program enters and exits various scopes, and at a point in execution identifiers are "in context" or "not in context"
Just be aware that these terms are often interchanged, even where it may not be entirely appropriate. So be prepared to make allowances where you see these terms used.