JavaScript - Standard In Using New Key Word
Solution 1:
JavaScripts garbage collector will process items as they fall out of scope, and are no longer reachable; this will be true for your Ajax.Updater
object regardless of whether you assign it to a variable or not.
So as to whether you should assign it to a variable or not? I wouldn't. It makes it clear that nothing else refers to that object again. If you assign it to a variable, people will start looking to see where that variable is used.
The garbage collector is very clever and intelligent. You seldom need to worry about whether the garbage collector will pick up something or not. In 99.99999999% cases, it will.
Solution 2:
You should only assign it to a variable if you subsequently need access to the object. Either way the object will be garbage collected, so you may as well save yourself a variable declaration and a few bytes.
Post a Comment for "JavaScript - Standard In Using New Key Word"