this post was submitted on 15 Jun 2023
9 points (100.0% liked)

Programming

13387 readers
13 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS
 

This is quite unclear to me, the definition of global object seem to be "The global object provides variables and functions that are available anywhere".

Now this surely means that the global variable environment contains variables available everywhere in the other scopes, but does this also mean that, for example, the window object is at the higher end of the scope chain? As in JS everything is an object, is this true for the prototype chain too? Because from my notes Object.prototype looks to be at the top of the prototype chain.

In fact if i do: Object.getPrototypeOf(window) i get WindowPrototype { … }

but if i do: Object.getPrototypeOf(Object.prototype) i get null

Another thing unclear to me is what is the difference between window (lowercase) and Window (uppercase).. I know that uppercases are usually used for constructors, is this the case too? Is Window a constructor and window an object? If so, what's the purpuose of the Window constructor?

you are viewing a single comment's thread
view the rest of the comments
[–] dontblink@feddit.it 1 points 1 year ago

Thank you so much! Now it's definetely clearer