Javascript Functions: Scope and Context

scope

Scope mostly refers to the use of your variables.

Imagine boxes inside one another. When we’re beginning a document, we’re in the global scope. As soon as the first function is written, we’re in the Local scope. Global code cannot access local code, but local code (functions) can access global. Access works from the inside out, just like the picture shows.

So when “scope” is used, it means the function for which your variables apply.

Context describes the invocation of the function, especially the use of the this  keyword.

Leave a Reply

Your email address will not be published. Required fields are marked *