What are Global Objects in Express.js?

_dirname and _filename are the global variable in global object.

  • _dirname returns the name of the current directory or module’s folder along with the path.
  • _filename returns the filename with the entire path.

Objects which are available throughout the process or applications are called global objects. These object are available in all modules. The objects listed here are specific to node.js. There are built-in objects that are part of the JavaScript language itself, which also globally accessible.