Link to home
Start Free TrialLog in
Avatar of chima
chima

asked on

Programming Registry equals

Hello;
How is Registry = { } used here, below.  In other words what is this statement doing in this function;
 function registerPerson(firstName, lastName)
  {
   var date = new Date(),
       counter = 0,
      registry = {},
       output;

Reference; http://milan.adamovsky.com/2012/02/javascript-memory-leaks-in-internet.html
If need to.
thanks
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of chima
chima

ASKER

CEHJ, I read the info at the link you provided, and the answer is not there.  Did you understand my question?  I had googled it, and of course most of the findings were about the MS OS registry.
I do not understand what this statement is doing;    registry = {},
Obviously the registry variable is getting information from the registry, but what and why?
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chima

ASKER

CEHJ, what is TA?  You posted a question to my question?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I stand corrected - sorry. 'empty object' it is, my bad. In fact the original article reference does go on to explicitly set registry to null:

  // locals
   date =
   counter =
   registry = null;

   return output;

I hope the point is not lost though that there really is no great significance in registry = {} it is really just an example the author has used to reach a conclusion about garbage collection.
Avatar of chima

ASKER

PortletPaul and Kravimir, so the word registry could have been any variable name, the point here is that it created an "empty object."  This empty object by using {} has properties and methods that could cause memory leaks, hence setting it to null, ensuring that the garbage collection will grab it.
Yes, that is my understanding as well.
the solution is to assist the garbage collector in JScript by marking the symbols with a null value that you want to be garbage collected.
I think so too. registry = {} could have been foobar = {}
Avatar of chima

ASKER

Thanks