Question: js named function in parameter, can not access out of function

Because the 5th edition of ECMAScript forbids use of arguments.callee() in strict mode.

[mdn warning](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments/callee?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FFunctions_and_function_scope%2Farguments%2Fcallee)

So I decided do not use the `callee`, instead , I use a named function

The example in mdn 

```
function factorial (n) {
    return !(n > 1) ? 1 : factorial(n - 1) * n;
}
[1,2,3,4,5].map(factorial);

```

become:

```
[1,2,3,4,5].map(function factorial(n) {
    return !(n > 1) ? 1 : /* what goes here? */ factorial(n - 1) * n;
});

```

This is a good idea, but I want to reuse the function `factorial`

**DEMO**

```
function d(x){return x;}

d(function a(){});
d(a);// this is not work, a is undefined(works in ie, failed in ff and chrome)

```

This is bother me, as I know, the scope in js is function-level, why the second a is undefined ?

[jsfiddle DEMO](http://jsfiddle.net/Wener/A6Y7X/)

Answer: 
You're really asking two questions here. The first is easy:

```
[1,2,3,4,5].map(function factorial(n) {
    return !(n > 1) ? 1 : /* what goes here? */ factorial(n - 1) * n;
});

```

What you've got there works just fine. In other words, since you're naming your function (factorial), that identifier is available inside the function body, enabling recursion.

Your second question is a little trickier:

```
function d(x){return x;}

d(function a(){});
d(a);// this is not work, a is undefined(works in ie, failed in ff and chrome)

```

It is correct for `a` to be undefined. If you read the [ECMAScript specification](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf), section 13.2.1 clearly states that new execution context that's created *includes* the actual parameters (argument list). That is, `a` is defined within the execution context of `d`, not the caller. It looks like IE is expressing erroneous behavior.
You say that your previous example doesn't work, but I have to disagree with you,

```
[1,2,3,4,5].map(function factorial(n) {
    return n == 0 ? 1 : factorial(n - 1) * n;
});

```

I tried this (yes I modified it a bit) using basic logging and it logged n-1 for every recursion indicating that the recursion works fine. I believe Paul explains just fine why.

I recommend, anyway, to change the way you're thinking here because imagine if you're finding factorial(100). You'd be doing

```
... * factorial(98 - 1) * 98 * 99 * 100

```

Imagine the overload. I recommend adding a optional parameter which is the sum of the currently evaluated factorials, your result is the same but the overload is way less.

```
[1,2,3,4,5].map(function factorial(n, sum) {
    var sum = sum || 1;
    return n == 0 ? 1 : factorial(n - 1, sum*n);
});

```