This is to make recursion work safely, I would guess.
For example, if you want to use only the name walk_the_DOM , this variable may be reassigned later or inaccessible due to the scope, so it is unsafe to use it inside the function itself.
UPDATE:
I did some research and this is what I found. First of all, refer to the ECMAScript 5 specification, section 13 . There are two ways to define a function: a) using FunctionDeclaration; and b) using FunctionExpression.
They look very similar, but also slightly different. The following is a description of FunctionDeclaration:
function f() { };
These two are FunctionExpression:
var x = function() { }; var y = function f() { };
The interesting part for us is FunctionExpression. In the case of var y = function f() { } identifier f displayed only from inside the body of the function. In other words, somewhere outside of { } , typeof f will return undefined .
Now it's time for some practical examples. Let's say we want to write a recursive function using FunctionDeclaration:
function f1(x) { x > 5 ? console.log("finished") : f1(x + 1) };
Now we want to "copy" the function to another variable and set f1 to something else:
var f2 = f1; var f1 = function() { console.log("Kitteh") };
But this does not work as expected:
f2(1);
Now, if you used the Douglas Crockford method to define a recursive function:
var f1 = function myself(x) { x > 5 ? console.log("finished") : myself(x + 1) };
This way you can reassign the function of any variable as many times as you want. At the same time, we guaranteed that the function always calls itself, and not any function assigned to the variable f1 .
So, the answer to the initial question: you define recursive functions this way because it is the most flexible and reliable way.