Javascript nodejs文件中函数的上下文是什么?

Javascript nodejs文件中函数的上下文是什么?,javascript,node.js,module,Javascript,Node.js,Module,nodejs文件中函数的上下文是什么? 如果我需要导出函数,我就写 module.exports = function () {}; or module.someFunction = function () {}; 但是,没有模块,什么样的上下文才有功能呢 function someFunction () {}; console.log(module); // not someFunction console.log(module.exports); // not someFunction

nodejs文件中函数的上下文是什么? 如果我需要导出函数,我就写

module.exports = function () {};
or
module.someFunction = function () {};
但是,没有模块,什么样的上下文才有功能呢

function someFunction () {};
console.log(module); // not someFunction
console.log(module.exports); // not someFunction
另外,我在哪里可以看到这个文件中声明的函数列表?在浏览器中,我有
窗口
。在nodejs中,我有
全局
模块
模块。导出
,但没有一个没有声明的函数

但是,没有模块,什么样的上下文才有功能呢

function someFunction () {};
console.log(module); // not someFunction
console.log(module.exports); // not someFunction
与普通JavaScript函数相同。在严格模式下,上下文将
未定义

(function() {
  'use strict';
  console.log(this === undefined);
})();
// true
以及在松散模式(非严格模式)下的全局对象

(function() {
  console.log(this === global);
})();
// true


注意:如果您想知道此指的是什么,在模块级,它将是导出对象。详细说明请参见。

它在浏览器中没有类似于
窗口的
上下文
!你说的“然后转向它”是什么意思?你说的“转向它”是什么意思?