【发布时间】:2016-02-07 12:19:05
【问题描述】:
这是我的 javascript 代码:
console.log(a);
c();
b();
var a = 'Hello World';
var b = function(){
console.log("B is called");
}
function c(){
console.log("C is called");
}
现在是输出:
undefined
hoisting.html:12 C is called
hoisting.html:6 Uncaught TypeError: b is not a function
我的问题是关于为什么 c() 和 b() 的行为不同。并且 b 应该抛出类似 b 未定义的错误。
【问题讨论】:
标签: javascript hoisting