Javascript anonymous objects lifetime

I have a standalone class object based on socket.io that takes an array of sockets on the server side and then just listens for client messages and sends responses back to clients. To run this function, I just need to instantiate this object by calling the following function, for example:

function CreateNetworkGame(clients) {
    new NetworkManager(clients);
}

I know this is not a very good practice, but it works only in the name of the science I want to ask: No variable refers to an instance of an object, so why does it not collect garbage and when will it be (if ever)?

+4
source share
2 answers

, . // , , , , NetworkManager.

, , , , , . , , NetworkManager .

+3

. . .

+1

All Articles