Since there are some pretty learned JS people reading this I thought I might get some good advice on a general question I have had for a long time. It applies to jQuery in that it applies to almost all JS development I do; which all uses jQ these days.
Is there value in using the delete operator? If you are not familiar with it here is the white paper version: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Operators:Special_Operators:delete_Operator There its use is defined as: delete variableName delete objectExpression.property delete objectExpression["property"] delete objectExpression[index] Although over at http://www.synchro.net/docs/js/ref/ops.html#1045837 the use is listed as: delete objectName delete objectName.property delete objectName[index] The only difference is the explicit mention that an object can be deleted as well as a variable. (note: variables defined with 'var' can NOT be deleted) Finally over at http://www.howtocreate.co.uk/tutorials/javascript/variables under the section "Deleting properties" the statement is made 'Of course, unless you have serious computer memory considerations, or security risks, it is usually not necessary to do this at all, since JavaScript engines clean up after themselves once the variable is no longer referenced.' It is that last statement that first got me started using delete when I worked on a large ajax style project. One of those single HTML file, the entire site loaded dynamically sort of things. It seemed that even though the JS Engine was supposed to do the cleanup for me, explicitly helping it along would be a good idea. Since then I have grown to an almost habitual usage of delete. For example: function(foo){ bar = foo + 3; if(bar < 10){...} delete bar; } Yet, I always have a nagging thought that maybe instead of helping performance I am actually taking a hit with the extra calls; and if there is a performance increase maybe the extra file weight is not worth the gains. Do you have any experience with this? Thank you for your thoughts, Wade Harrell