JavaScript - what's the difference between scope and context?

0 points
Asked by:

I'm not really sure what is the difference between scope and context in JavaScript.

Can someone help me understand?

1 answer
0 points
Answered by:


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 this keyword.



  • 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 this keyword - a reference to the object to which the currently executing code belongs.
0 comments Add comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

â€ïžđŸ’» 🙂