JavaScript Hoisting

JavaScript hoists function declarations and variable declarations to the top of the current scope.

Variable assignments are not hoisted.

Declare functions and variables at the top of your scripts, so the syntax and behavior are consistent with each other.

函数被提升了,即函数定义可以在函数使用之后。但请注意:Function Hoisting仅适用于使用函数声明方式定义的函数。这是我要分开讲变量提升和函数提升的一个重要原因。
当命名的函数作为函数表达式的一部分时,不会被提升。
扩展:
http://creeperyang.github.io/2014/10/javascript-hoisting/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容