uArr
is just a local variable that is allocated, used, and then garbage collected after check()
exits. And there is no closure inside check()
. setTimeout()
is invoked (but not defined) by check()
.
This page on Closures may be helpful.
While it is true that if there are N calls to check()
, there would have been N closures created (as well as N copies of node
), setTimeout()
will release its reference to check()
after it calls it. Therefore, there is no leak there either.