function a() {} vs. var a=function(){} vs (function a(){})

1. Javascript 函数和变量声明的“提前”hoist 行为

2. 函数名a提前了,函数主体body不会被提前,只有在被调用时才被初始化

3. 为什么会出现这种情况? js编译的顺序是怎样的?

answer: http://dmitrysoshnikov.com/ecmascript/chapter-2-variable-object/#introduction

猜你喜欢

转载自www.cnblogs.com/KellyChen/p/9048454.html