I am wondering if the following jquery code causes any memory leak:
$( function() {
var parent=$('table#mytable tbody').get(0);
$('tr:last', parent).click(function(){...});
});
For my understanding, $('tr:last', parent)
is the last row which is the DOM object, but in the anonymous function, the closure has this DOM object in scope, so there is a circular reference between DOM and js objects.
But if it really has leak, then I can see there are many such kind of code in the popular book "jQuery in Action" published by Manning. It is harmful "best practice" in jQuery coding?
But i don't know if my understanding is correct. I hope your comments and corrections. Thanks!