About Context
Context is related to objects. It refers to the object within which a function is executed.
-
When you use the
newkeyword in front of a function call, the context is the newObject. -
When you execute a
Functionusing.callor.apply, the context is the first argument. -
If a
Functionis called as object property (likeobj.fn) then is executed in the context of theObject. -
If any of this rules don’t match with your case, the
Functionis executed in the global context.
About Scope
Scope has to do with the the visibility of variables. In JavaScript, scope is achieved through the use of functions
-
Each function creates a scope, and the only way to create an scope is defining a
Function. -
The life cycle of an variable exists in the most external scope that the variable has been assigned.
-
Out of his scope, a variable is invisible.
Read in the CoffeeScript Book by soyjavi.
Quotes from Kevin Chisholm blog.