In what scope are module variables stored in node.js?

后端 未结 4 676
醉酒成梦
醉酒成梦 2020-11-22 02:34

When I do this in my node.js module:

var abc = \'123\';

Where does it go? And by this I mean: in the browser it goes in window.abc

4条回答
  •  [愿得一人]
    2020-11-22 03:35

    Pretty old question, and if anyone is curious about ECMA specs about this question, here is the link

    And there is no way for direct access for module variables (except for imported modules):

    Lexical Environments and Environment Record values are purely specification mechanisms and need not correspond to any specific artefact of an ECMAScript implementation. It is impossible for an ECMAScript program to directly access or manipulate such values.

提交回复
热议问题