minitech answer is quite good, but it is missing one more scenario. Your declare function called callback, which means two things, first the function is object in memory, and the second, the function name is only for referencing to the object. If you, for any reason break the reference between these two, the proposed code will not work too.
Proof:
function callback() {
// ...
setTimeout(callback, 100);
}
setTimeout(callback, 100);
var callback2 = callback; //another reference to the same object
callback = null; //break the first reference
callback2(); //callback in setTimeout now is null.
From developer Mozilla page in the description is:
Warning: The 5th edition of ECMAScript (ES5) forbids use of
arguments.callee() in strict mode. Avoid using arguments.callee() by
either giving function expressions a name or use a function
declaration where a function must call itself.
obviously this is the first example of workaround "by either giving function expressions a name", but lets see how we can deal with "or use a function declaration where a function must call itself" and what will that bring:
function callback(){
//...
setTimeout(innercall(), 100);
function innercall(){
//innercall is safe to use in callback context
innercall.caller(); //this will call callback();
}
}
Then we are safe to do whatever we want with the callback reference:
var callback2 = callback;
callback = null;
callback2(); //will work perfectly.