fruity4pie
@fruity4pie
A

Лексическая среда JS?

В учебнике Кантора в разделе "Глобальный объект", говорится:

The global object is not a global Environment Record
In versions of ECMAScript prior to ES-2015, there were no let/const variables, only var. And global object was used as a global Environment Record (wordings were a bit different, but that’s the gist).

But starting from ES-2015, these entities are split apart. There’s a global Lexical Environment with its Environment Record. And there’s a global object that provides some of the global variables.

As a practical difference, global let/const variables are definitively properties of the global Environment Record, but they do not exist in the global object.

Naturally, that’s because the idea of a global object as a way to access “all global things” comes from ancient times. Nowadays is not considered to be a good thing. Modern language features like let/const do not make friends with it, but old ones are still compatible.


А в разделе "Замыкания" в пункте Лексическая среда:

The Lexical Environment object consists of two parts:

Environment Record – an object that has all local variables as its properties (and some other information like the value of this).
A reference to the outer lexical environment, usually the one associated with the code lexically right outside of it (outside of the current curly brackets).


Почему именно let/const не доступны в объекте window в виде свойст если window - это объект, который имеет свою ER и LE.
  • Вопрос задан
  • 133 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы