It is clear that an anonymous function has no name. Are there any other differences than the specified? In particular, she is interested in what execution context she owns besides her own, and that is, which namespace she has access to.
- In fact, there are no anonymous functions, there are anonymous functional expressions - Grundy
- In particular, she is interested in what execution context she owns besides her own, and that is, which namespace she has access to. - this part of the question is incomprehensible - Grundy
- @Grundy, well, there is an internal space (this is its body), the external (the body of the function from which it was called the local space) is the global space (this is the body of the file itself where it exists). - perfect
- and how does this relate to the execution context ? :-) - Grundy
- in a nutshell: there is no difference - Grundy
|
1 answer
From the point of view of behavior ( this definition, creation of closures, declarations inside variables ) the difference between the named and anonymous function is not .
If you refer to the specification , you can note that the functions can be divided into FunctionDeclaration and FunctionExpression .
FunctionDeclaration can be anonymous only when declaring it as an export default ; in doing so, when creating a function object, it is given the name default .
As for the FunctionExpression : the named FunctionExpression can be referred to in its body by name, which allows you to make recursive calls.
- And what does it mean to declare as
export default? I have not seen such a specifier. - perfect - @perfect, this applies to modules: Use_export_ by default - Grundy
- thanks for the clarification - perfect
|