Where are the global variables declared by let?

read teacher Ruan Yifeng"s blog that ES6 in order to change this, on the one hand, in order to maintain compatibility, the global variables declared by the var command and the function command are still the attributes of the top-level object; on the other hand, the global variables declared by the let command, the const command and the class command do not belong to the properties of the top-level object. That is, starting with ES6, global variables are gradually decoupled from the properties of the top-level object.
then comes the question of attributes that do not belong to the top-level object. Who does that belong to?

Apr.07,2021

Why do you have to belong to someone?

if a variable is defined in a function, does it belong to a function?

function foo() {
    var a = 'bar';
    return a;
}

can you access the value of a via foo.a ? I can't.

The

global variable simply no longer exists as a property of the global object, but is still in the global scope .

Menu