-9

Can someone tell me what is happening here?I only know that it is requiring some core modules.

var inherits = require('util').inherits;
var express = require('express')();
Raaz
  • 1,669
  • 2
  • 24
  • 48

1 Answers1

0

The util module has exported an object that contains (probably amongst others) a function under the key inherits:

exports = {
    inherits: function() ...
}

The express module on the other hand, has directly exported a whole function, and that function is immediately invoked and the result assigned to the variable express.

module.exports = exports = function() {
    return ...
}

It is likely that the function has also returned an object containing key/value pairs of functions, just like you'd get from a normal exports object.

See also What is the purpose of Node.js module.exports and how do you use it?

Community
  • 1
  • 1
Alnitak
  • 334,560
  • 70
  • 407
  • 495