What does “this” mean in a nodejs module?

Deadly 提交于 2019-11-26 17:25:25

问题


I have a simple codes like the following and execute it as a node module:

console.log(this);
module.exports = {…};

I know that global is the default context (like window in browsers), but what does the this keyword refer to?


回答1:


this (in the context of a module) is the same as exports in node.js. However you should generally use exports/module.exports instead, so that it's explicitly clear what you're modifying.



来源:https://stackoverflow.com/questions/25058814/what-does-this-mean-in-a-nodejs-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!