Closures are functions that inherit variables from their enclosing environment. So lets see this code:
binaryServer = BinaryServer({port: 9001});
binaryServer.on('connection', function(client) {
console.log("new connection");
client.on('stream', function(stream, meta) {
stream.on('data', function(data){
//actions
});
stream.on('end', function() {
//actions
});
});
});
So, I am correct if I say: " function(data){//actions}
is a closure because inherits the variables of enclosing environment (like the object client
) "? Because of my experiences that's what happening.