Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
Deleting an anonymous function
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="RobG, post: 4975339"] Leave them for the garbage collector. Do you attempt to explicitly remove named functions? It seems to me that: var foo = function(){ /*foo body */ }; foo(); foo = null; results in the function formerly referred to as foo becoming anonymous and, if there are no other references to it, it becomes available for garbage collection. It is, more or less, equivalent to: (function(){ /*foo body */ })(); provided foo isn't called from elsewhere before being set to null. It depends on what you interpret from the phrase "seems to work". The arguments object belongs on to the execution context, it is given a 'callee' property that refers to the anonymous Function so that it can be recursive. It has the property DontEnum, but is not specified as being ReadOnly so you can set it to anything you like without causing an error (in a browser conforming to ECMA-262, section 10.1.8). Setting arguments.callee as a reference to some arbitrary object doesn't seem to do anything useful and should have zero effect on when the function is made available for garbage collection. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
Deleting an anonymous function
Top