Scope = VO + All Parent VOs what does that mean? I understand.

Scope = VO + All Parent VOs
scopeChain = [[VO] + [VO1] + [VO2] + [VO nomenclature 1]];
what"s the difference between a collection of all variable objects?

Sep.26,2021

after entering the context and creating the AO/VO, the Scope attribute of the context = AO | VO + function [[scope]]

 
Scope  three() Scope Chain = [ [three() VO] + [two() VO] + [one() VO] + [Global VO] ];

Scope = [AO].concat([[Scope]]);  <---


var x = 10;
function foo () {
var y = 20;
function bar () {

var z = 30;
alert(x +  y + z);

}
bar ();
}
foo (); / / 60

Global context

global_Context.VO===global={
    x=10
    foo:
}

foo function creation

foo.[[scope]]={
    global_context.VO
}

foo function activation (when entering context)

foo_context.AO={
    y:20
    bar:
}

scope chain of foo function context


foo_context.scope=foo_context.AO+foo.[[scope]]

foo_context.scope=[
    foo_context.AO,
    global_context.VO
    ]

bar function creation

bar.[[Scope]] = [
  fooContext.AO,
  globalContext.VO
];

bar Activation

barContext.AO = {
  z: 30
};

scope chain of bar function context

barContext.Scope = barContext.AO + bar.[[Scope]] // i.e.:
 
barContext.Scope = [
  barContext.AO,
  fooContext.AO,
  globalContext.VO
];

the following is the query process for x y z identifiers:

"x"

  barContext.AO // not found
  fooContext.AO // not found
  globalContext.VO // found - 10

"y"

  barContext.AO // not found
  fooContext.AO // found - 20

"z"

  barContext.AO // found - 30




Menu