I am wondering how to properly destroy an object in Javascript that contains an array among other data.
For example (this is the initial state of the object):
acme.models.nomination = { recipients : [],
The application uses the nomination.recipients object, as well as other data elements. Is it enough to do the following to clear the complete object when it is finished with it:
acme.models.nomination = {};
or is it better (or overkill):
acme.models.nomination.privacy = undefined; acme.models.nomination.awardType = {}; acme.models.nomination.recipients = {}; acme.models.nomination = {};
I think that the previous statement (i.e. acme.models.nomination = {} ) is enough, since it actually makes all the content inaccessible and therefore has the right to garbage collection. However, I would like to get other people's opinions on this. BTW, the answer can be given in the modern browser context, say post-Jan-2012 browsers, since I know that memory management was a bit inconsistent in the past.
source share