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

后端 未结 4 680
醉酒成梦
醉酒成梦 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

    Node has a module scope, so var abc = '123' in a module will create a variable which is scoped to (and therefore, reachable only for code in) that module.

    See also http://nodejs.org/api/globals.html#globals_global

提交回复
热议问题