答案
输出是抛出异常,bar is not defined。
解析
这种命名函数表达式函数只能在函数体内有效
var foo = function bar(){
// foo is visible here
// bar is visible here
console.log(typeof bar()); // Work here :)
};
// foo is visible here
// bar is undefined here
typeof(bar). // "undefined"
typeof(foo()). // "number"
typeof(foo). // "function"
typeof(bar()). // VM5167:1 Uncaught ReferenceError: bar is not defined
Most helpful comment