Hoisting between different files

前端 未结 3 1280
被撕碎了的回忆
被撕碎了的回忆 2021-01-21 22:13

Is there a way to do functions and variable hoisting between source code present in different files? That is, something like

//Inside firstfile.js
foo === \"bar\         


        
3条回答
  •  时光取名叫无心
    2021-01-21 22:31

    I originally thought this was a more interesting question than it actually appears. The answer to the question I thought this was is that each

    ... alerts "function" because the function declaration is hoisted, but splitting the two lines into separate

    ... alerts "undefined", because the first script is executed before the second script is even parsed.

提交回复
热议问题