为什么<anonymous>出现在此堆栈跟踪中?</anonymous>

时间:2014-10-07 21:59:08

标签: javascript

为什么<anonymous>出现在此堆栈跟踪中?脚本中的每个对象和函数都有一个名称,那么它的匿名是什么?

剧本:

function weAllHaveNames(cb) {
  cb();
}

weAllHaveNames(function iHaveAName(){ var x = y.a; });

堆栈跟踪:

weAllHaveNames(function iHaveAName(){ var x = y.a; });
                                              ^
ReferenceError: y is not defined
    at iHaveAName (/Users/Trindaz/code/scratchpad/funcs.js:5:47)
    at weAllHaveNames (/Users/Trindaz/code/scratchpad/funcs.js:2:3)
    at Object.<anonymous> (/Users/Trindaz/code/scratchpad/funcs.js:5:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

0 个答案:

没有答案