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: 
The name of a *function expression* does not reference itself in the namespace it's defined in (IE bugs on this) but does reference itself within itself

```
[1].map(function foo() {return foo;});
// [function foo() {return foo;}]
foo;
// undefined

```

If you want a reference to the *function* so it can be re-used, create a reference to it, either go back to writing a *function declaration* (*function* as a statement), or set the *function expression* as a variable, and pass the variable as desired

```
var bar = function foo() {return foo;};
[1].map(bar);
// [function foo() {return foo;}]
foo;
// undefined
bar;
// function foo() {return foo;}

```

Note that inside the *function* named `foo` in this example, both `foo` and `bar` will point to the same *function*, unless `bar` is changed again later.

```
var bar = function foo() {return foo === bar;};
bar(); // true, bar is foo inside the function
// change value of bar, keep a reference to function foo
var temp = bar;
bar = 'something else';
temp(); // false, bar is no longer foo inside the function

```
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);
});

```