Can someone help me understand?
Scope determines the visibility (or accessibility) of variables. It's achieved by the use of functions and curly braces. Variables can be defined either in local or global scope.
Here are some runnable examples:
Context is related to objects and how a function is invoked. It refers to the object to which a function belongs when you use
- scope is function-based while context is object-based,
- every function call has both a scope and a context associated with it,
- context is associated with
thiskeyword - a reference to the object to which the currently executing code belongs.