1 ) environmentRecord - 호이스팅
2 ) outer-environmentReference - 스코프
실행컨텍스트는 수집자료를 총 2가지를 한다. ( 호이스팅 + 스코프 객체 )
var a = 10;
var outer = function () {
var inner = function () {
console.log(a); //undefined : 호이스팅을 생각하면 될듯! 함수 내에 매개변수로 받은것은 없지만,
a라는 식별자를 받았기 때문에 스코프체인을 하지 않고 undefined를 출력한 것.
var a = 20;
};
inner();
console.log(a) // 10 출력 : outer 함수내에서는 a 변수가 없어서 undefined가 나올거라 생각했지만,
outer 변수의 LexicalEnvironment는 window 객체 이기 때문에 10이 출력된다.
}
console.log(a);
----------------------------------------------
var a = 10;
var outer = function () {
var b= 1004 ;
var inner = function () {
console.log(b); //1004
}
inner();
console.log(a) // 10
}
console.log(a);
1 ) VariableEnvironment
2 ) LexicalEnvironment
3 ) ThisBinding