Why can I use a function before it's defined in JavaScript?

前端 未结 7 1855
日久生厌
日久生厌 2020-11-22 16:07

This code always works, even in different browsers:

function fooCheck() {
  alert(internalFoo()); // We are using internalFoo() here...

  return internalFoo         


        
7条回答
  •  甜味超标
    2020-11-22 16:52

    I have only used JavaScript a little. I am not sure if this will help, but it looks very similar to what you are talking about and may give some insight:

    http://www.dustindiaz.com/javascript-function-declaration-ambiguity/

提交回复
热议问题