Declaration and expression are different. If you declare, not only the definition will be done in advance, but the assignment will also be done in advance, but the expression will not. For example:
a();
function a(){}; //等同于
var a = function(){};
a();
///////对于表达式有
a();
var a = function(){}; //等同于
var a;
a();
a = function(){}; //简单来讲就是表达式的赋值必须要等程序运行到相关行的时候才会进行
When we write js code, we have two ways of writing, one is function expression, and the other is function declaration.
What we need to focus on is:
1. Function declaration form [Success]
2. Function expression method [Failure]
Read my article: http://www.jianshu.com/p/85a2...
Function expressions are not hoisted.
Read "Javascript Advanced Programming" again.
Declaration and expression are different. If you declare, not only the definition will be done in advance, but the assignment will also be done in advance, but the expression will not. For example:
Same as above, your function creation method is in function literal form, change it to
That’s it