[英]Is there any other use of naming a function that is being assigned other than recursive calling itself?
If I say:如果我说:
let F = function G(){}
What is destination of identifier G
?标识符G
的目的地是什么?
Is there any other reason to name it other than use it for recursion?除了将其用于递归之外,还有其他理由命名它吗?
Is there a way that I could access identifier G
?有没有办法可以访问标识符G
?
The name of functions is shown in the stack trace, if there is an exception thrown.如果抛出异常,函数的名称会显示在堆栈跟踪中。
The name will typically also be shown in the debugger's scope window:该名称通常也会显示在调试器的 scope window 中:
For these two reasons, naming anonymous functions can make debugging easier, especially when dealing with complex call structures with many anonymous functions.由于这两个原因,命名匿名函数可以使调试更容易,尤其是在处理具有许多匿名函数的复杂调用结构时。
If for some reason, you want to access the name of the function, you can do so with F.name
如果出于某种原因,您想访问 function 的名称,您可以使用F.name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.