I've recently started learning about javascript and have been following a tutorial series that delves into the inner workings of sockets. You can check it out here.
The tutorial demonstrates the following code snippet:
var io = socket(server);
io.sockets.on('connection', newConnection);
function newConnection(socket){
console.log('new connection' + socket.id);
}
I'm curious about how the 'newConnection' function works within the 'sockets.on'. It requires a 'socket' parameter, but seems to be a reference to the function itself. I've heard about callbacks before, but I'm still unclear on what's actually happening here. Could someone provide an explanation?