An additional wrinkle: recursive functions. If you've got a recursive function, you absolutely must use a function declaration to introduce the function identifier. Otherwise you inadvertently create a closure. Consider:
var a = function(b) {
if (b === 0) {
return true;
}
return a(--b);
};
var b = a;
a = function() { return false; };
b(5);
As an alternative, you should go
var a = function a2(b) {
if (b === 0) {
return true;
}
return a2(--b);
};
var b = a;
a = function() { return false; };
var a2 = function() { return false; };
b(5);
Perhaps counterintuitively, a2 doesn't leak into the containing scope, which makes it safe to use within the function it declares.
you can use the same name for both the variable and the function in your (alternative) solution. It's better and less confusing. and another reason your alternative is preferred is because arguments.callee is going away (if it isn't gone already) :/
Indeed. Having separate names was for didactic purposes. In real code, naming the variable the same as the function would be very strongly recommended.
Some older browsers fuck this up though, IIRC.