I am wondering if the following jquery code is causing a memory leak:
$( function() { var parent=$('table#mytable tbody').get(0); $('tr:last', parent).click(function(){...}); });
In my understanding, $('tr:last', parent) is the last line that is a DOM object, but in an anonymous function, the closure has this DOM object in scope, so there is a circular link between the DOM and js objects.
But if it does have a leak, then I see that in the popular jQuery in Action book published by Manning there are many such types of code. Is this a harmful "best practice" in jQuery coding?
But I do not know if I understand correctly. Hope your comments and corrections. Thanks!
source share