I'm following the socket.io chat application tutorial here - https://socket.io/get-started/chat/
and it's using express framework. There's a code in the tutorial that is:
var app = require('express')();
var http = require('http').Server(app);
and if I just use 'require('express')' without the second parenthesis it doesn't work. What does the second parenthesis do and where could I find documentation for the syntax?
The type returned from require('express')
is a function. The second set of parenthesis is you actually invoking the function to create an instance of an express app.
It's the equivalent of you doing
const express = require('express');
const app = express();