4 A detailed look at global variables Please support this book: buy it or donate 4 A detailed look at global variablesIn this chapter, we take a detailed look at how JavaScript’s global variables work. Several interesting phenomena play a role: the scope of scripts, the so-called global object, and more. 4.1 Scopes4.2 Lexical environments4.3 The global object4.4 In browsers, globalThis does not point directly to the global object4.5 The global environment4.6 Conclusion: Why does JavaScript have both normal global variables and the global object?4.7 Further reading and sources of this chapter