Context vs Scope

Sang
Written by Sang on
Context vs Scope

Scope

Scope is a function based thing. Scope mean what is the variable access of a function when it is invoked and what is in the variable environment.

Context

Context on the other hand is more about object based. For example…the value of this keyword which is a reference to the object that owns that current executing code.

Summary

  • Context is most often determined by how a function is invoked with the value of this keyword.
  • Scope refers to the visibility of variables.