I have browsed many similar questions and ECMA262 2022 for some days, but still don’t know why.
- I know LE is the same as VE originally, does it means that they point to one Environment Record.
- in the top level of the script, if contains
let
orconst
declarations, will a new Environment Record be created and LE point to it?
Am I right to think it as following?
let a = 1
var b = 2
console.log(a)
---------------------------
// Pseudo codeļ¼
// which right? or other else
global Execution Context = {
VE: {
bindings: b
[[outerEnv]]: null
},
// create a new ER whose [[outerEnv]] is null. then LE point to it.
LE: {
bindings: a
[[outerEnv]]: null
}
}
or
global Execution Context = {
VE: {
bindings: b
[[outerEnv]]: null
},
// create a new ER whose [[outerEnv]] is the original ER (which the unchangeable VE point to)
// then LE point to it
LE: {
bindings: a
[[outerEnv]]: VE
}
}