What are Global objects in Node.js?
Node.js has some Global objects which are available in all modules. Some of these objects are not actually in global scope but in the module scope.
__dirname
: The directory name of the current module. This the same as thepath.dirname()
of the__filename
.__filename
: The file name of the current module. This is the resolved absolute path of the current module file.exports
: A reference to themodule.exports
that is shorter to type.exports
is not actually a global but rather local to each module.require
: To require modules.require
is not actually a global but rather local to each module.
Comments
Post a Comment