a
Есть код
https://codepen.io/bruha1991/pen/vYKRNob?editors=1112
Почему в строке
sayHelloWindow: hello.bind(this)
this=window а не person?Size: a a a
АМ
sayHelloWindow: hello.bind(this)
this=window а не person?ᅠ
sayHelloWindow: hello.bind(this)
this=window а не person?sayHelloWindow: hello.bind(this)
у тебя this == globalThis == window, а не personSD
꧁岡
АМ
DM
DM
This is an example of lexical scoping, which describes how a parser resolves variable names when functions are nested. The word lexical refers to the fact that lexical scoping uses the location where a variable is declared within the source code to determine where that variable is available.
Это пример лексической области видимости, которая описывает как парсер разрешает имена переменных, когда функции вложены друг в друга. Слово "лексический" указывает на тот факт, что лексическая область видимости использует место в коде, где объявлена переменная чтобы определить где эта переменная доступна
АМ
This is an example of lexical scoping, which describes how a parser resolves variable names when functions are nested. The word lexical refers to the fact that lexical scoping uses the location where a variable is declared within the source code to determine where that variable is available.
Это пример лексической области видимости, которая описывает как парсер разрешает имена переменных, когда функции вложены друг в друга. Слово "лексический" указывает на тот факт, что лексическая область видимости использует место в коде, где объявлена переменная чтобы определить где эта переменная доступна
DM
DM
hello.bind(this)
очевидно? )АМ
DM
bind
аргументом можно передать _что угодно_DM
bind
, то и будет в this
у функцииАМ
DM
this
DM
DM
DM
DM