javascript – What is the difference between an anonymous function and a named one?


It is clear that the anonymous function has no name. Are there any other differences besides the one indicated? In particular, she is interested in what execution context she owns besides her own, that is, what namespaces she has access to.


In terms of behavior (determination of this , the creation of circuits Offers in the variables) the difference between named and anonymous function – no.

If you refer to the specification , you can note that functions can be divided into FunctionDeclaration and FunctionExpression .

A FunctionDeclaration can be anonymous only when it is declared as export default , and when the function object is created, it is named default .

As for FunctionExpression , a named FunctionExpression can be referenced in its body by name, which allows recursive calls.

Scroll to Top