Is there an es6 module-scope equivalent to `window`?

前端 未结 1 510
自闭症患者
自闭症患者 2020-12-21 02:39

In Javascript, we can add global variables at any point using the window object:

相关标签:
1条回答
  • 2020-12-21 02:51

    Module environments consist of so called declarative environment records:

    A module Environment Record is a declarative Environment Record that is used to represent the outer scope of an ECMAScript Module.

    In contrast to the global environment consist of an object environment record:

    Each object Environment Record is associated with an object called its binding object. An object Environment Record binds the set of string identifier names that directly correspond to the property names of its binding object.


    Just like with function environments (they are also declarative), there is no way to access the scope from another scope.

    0 讨论(0)
提交回复
热议问题