58. JavaScript Execution Context 2: What is Scope Chain? What is Lexical Scoping? Nested Function?

preview_player
Показать описание
#MissXing #JavaScript #javascript
In this video, I continued to explain Execution Context with 3 different demos. The demos are related to Scope Chain, Lexical Scoping in JavaScript.
Рекомендации по теме
Комментарии
Автор

hi another question:

function b(m, n) {
function a(i, j) {
console.log(x);
}
a(5);
const x = 10;

}
const x = 20;
b(7, 8, 9);

why does a() get a reference error in this case? I know that function a() outer is referencing b() lexical environment and b() has x in the TDZ during a() execution. But wouldn't a() execution phase find that there is no x in it's parent's lexical environment (since it's in TDZ), thus it should search the global lexical environment where it's defined as 20 no?

tenzl
Автор

console.log() creates an execution context too right?

tenzl
join shbcf.ru