What does it mean when it says that this’s value is the global object? What is the global object in this case?
The global object is the entire context all JavaScript operations are conducted in. In the web browser, the global object would be window
. Note that window
also contains document
as window.document
. And a function defined as function a(){}
is added to this context as window.a()
.
Pragmatically, the global object in web browsers is the window
object. function a(){ console.log(this); }
logs the window
object.
2 Likes