5
In a simple chat project, which I have already used and works 100%, it is used
const express =require('express');//para http
const app = express();//instancia
const http = require ('http').createServer(app);
const io = require('socket.io')(http);
I have already looked for a specific answer, but I still haven’t found the meaning of the application of this http object in parentheses, at ('socket.io')(http).
What do these parentheses mean? They mean an anonymous function associated with require?
I don’t understand how this works and, like, when to use.
Very good explanation. However, every particularity, every exception, confuses us, as in the line ... case '+': Sum Return; ... Here, the 'sum' function is provoked without the parentheses and the necessary arguments and, even so, it gives the message. It’s hard to keep track of all these syntax details.
– user4701
@Maurosimoes over time we get used to the nuances of each language, haha, but basically, when you don’t put the parentheses in the name of a function, javascript understands that it should return the function as a whole. Just as you can assign a function to a name like
const minhaFunc = fuction() {}
and then just call his nameminhaFunc
(:– Felipe Avelar
you spoke, it is spoken. Who knows, knows; who does not know, ask.
– user4701