deferred.resolve() - query on usage as a callback
In
this question on Stackoverflow, I suggested use of $.Deferred()
My original fiddle for a solution used a separate callback function which just called def.resolve().
However I then remembered that I've seen other code simply pass "def.resolve" as a callback in its own right. I tried this instead, and it works (see http://jsfiddle.net/Nyg4y/3/).
This got me wondering - how does this work? As I understand it for this to work at all the value 'def.resolve' must be specific to 'def'.
This suggests that it is actually a (reference to a) closure holding a reference to 'def' in its scope. Is my understanding correct, and if so is this behaviour guaranteed?