全局上下文
全局代码
函数上下文
函数代码
eval上下文
eval代码
作用域链
Scope chain
this
变量对象
Variable object
Calling context:
全局上下文
Calling context:
test上下文
EC 栈
inner EC
全局 EC
foo ECeval EC
全局上下文
全局对象
函数上下文
激活对象
eval上下文
Calling
context.vo
内置
NaN
undefined
parseFloat
eval
parseInt
Object
Function
……
用户添加
……
宿主环境
window
alert
……
{ DontEnum }
function test(y){
var x
function x() {}
}
test(1);
function test(y){
alert(x);
var x = 10;
alert(x);
x = 20;
function x() {}
alert(x);
alert(y);
}
test(1);
function test(y){
alert(x);
x = 10;
alert(x);
x = 20;
alert(x);
alert(y);
}
test(1);
全局上下文
scope chain = [全局对象]
函数上下文
scope chain = 激活对象 + function.[[scope]]
eval上下文
scope chain = calling context.scope chain
function.[[scope]] =
函数创建时所在EC.scope chain
base object test ao
property name x
标示符解析
Identifier Resolution
1.从作用域链中
取下一个元素
Result(1).[[HasProperty]](Identifier)
No
Yes
base object Result(1)
property name Identifier
Yes
No
base object null
property name Identifier
 确定当前变量属于作用域链中的哪个
变量对象
 永远返回Reference
全局上下文
this = 全局对象
eval上下文
this = calling context.this
函数上下文
this = ?
函数调用语法:
表达式 ( );
是否是
Reference
是否是激活
对象
global object
global object
Reference.base object
Yes No
Yes No
求值
Ecma script3
Ecma script3
Ecma script3

Ecma script3