13

In a given execution context, the Variable object is the Activation object of that execution context.

From my research online, I am able to find the previous sentence rephrased in different ways but no one is able to tell what it is.

What is an Activation object?

1
  • An activation object is the uppermost object in a scope-chain with the lowermost being global object. See this answer for more details.
    – ikaruss
    Jan 24, 2014 at 3:20

2 Answers 2

17

Let me start from the roots...

Execution context is an object which consists of:

  • variable object, which is activation object in case of functions
  • scope chain, which you can think of as a linked list of outer scopes
  • this value

Variable object is an abstract thing, which can be either one of those:

  • global object (in global context) - the place where global vars (like window, document or console in a browser) reside
  • activation object (for functions, which define scopes in ECMAScript)

Activation object is an object which holds:

  • formal args of the function
  • arguments object for this function
  • any vars and (named) functions inside this function

So, activation object is just a special case of variable object.

It is basically a container for all the local stuff you can access by name inside a function, except for this. I may be imprecise here, but that's what I think it is.

More explainations with some nice pictures:

2

An Activation object is the object used to hold the properties that describe the environment and scope of an executing function. It is on this object that function arguments for example, are stored. By definition, to ACTIVATE something is to cause that thing to act or FUNCTION. So when you hear 'Activation object', think 'FUNCTION' object, or better yet, the root object that is LOCAL to a function (i.e., the FUNCTION LOCAL OBJECT).

With regards to the Variable object, an Activation object is more or less a concrete instance of a Variable object, which is itself (referring to the Variable object here) an ABSTRACT object type. As stated here...

The term ‘Variable object' is a general or abstract term used to refer to any object that holds the properties that describe the environment and scope of the currently executing context.

Hence, within the environment and scope of the global execution context (i.e., when outside of a function), the Global object is the Variable object. In the browser, because the global or outermost executing environment is the browser WINDOW, it is the window object that ends up being used as the Variable object. This is why variables declared with the var keyword outside of functions end up on the window object.

In the scope of a function, however, it is the Activation object (i.e., the function local object) that is the variable object because it is this object that is used to store the properties that describe the scope of an executing function.

Not the answer you're looking for? Browse other questions tagged or ask your own question.