为什么在JavaScript中定义函数之前就可以使用它?
即使在不同的浏览器中,此代码也始终有效: function fooCheck() { alert(internalFoo()); // We are using internalFoo() here... return internalFoo(); // And here, even though it has not been defined... function internalFoo() { return true; } //...until here! } fooCheck(); 但是,我找不到关于为什么它应该起作用的单一参考。我首先在John Resig的演示文稿中看到了这一点,但仅被提及。那里或任何地方都没有解释。 有人可以启发我吗?