Consider the following snippet:
let myFunc = function foo() {
console.log('whatever');
}
myFunc(); // 'whatever'
foo(); // ReferenceError
What reason is there to give this function a name if you can't use it?
Consider the following snippet:
let myFunc = function foo() {
console.log('whatever');
}
myFunc(); // 'whatever'
foo(); // ReferenceError
What reason is there to give this function a name if you can't use it?
A named function is to call itself with this given name. The name can not changed later.
For example this function is calling itself only two times.
let myFunc = function foo() {
console.log('whatever');
foo.count = (foo.count || 0) + 1;
if (foo.count < 3) foo();
}
myFunc();