为什么在 chrome 开发工具中调用命名函数被视为匿名?

Why is the invocation of a named function considered anonymous in chrome dev tools?

我有一个叫做 doStuff 的函数 函数 doStuff(prop){ console.log(道具) } 我像这样调用函数: doStuff('boop');

问题: 为什么 chrome 开发工具将 doStuff('boop') 调用 line 4 视为 (anonymous function)

来自https://developer.chrome.com/devtools/docs/javascript-debugging#call-stack-panel

The Call Stack panel displays the complete execution path that led to the point where code was paused

所以你得到的“(anonymous function)”指的是函数的调用者。

在您的示例中,您从 "top" 执行过程中调用它,该过程在浏览器完成加载脚本时发生。因此,没有调用者,devTools 然后将其视为 anonymous function 调用。