function test(){
return 123;
}
Obviously this is a function declaration, what about the following
var b=function(){return 123};
Everyone is suspicious of this. It doesn’t seem to be a declaration, because the function has no name, it is just an anonymous function. Well, look again
var b=function test(){return 123};
Is this a function declaration? It seems so, then I will answer you "no"
alert(test);
var b=function test(){return 123};
You can test it on any js implementation other than IE, and an undefined test error will be reported. What if this is the case
var b=function test(){return 123};
alert( b);
alert(test);
will display the toString result of function test(){...}, but the second alert is still abnormal. Why? That is to say, function test(){return 123} here is not a statement, but a function object. The reference is just placed in b. Therefore, the function object is not bound to the test name by default like the declaration. Then why don't I call it Use ie to test, because
alert(test);
var b=function test(){return 123};
ie will display the function, ie is stupid, so It will distinguish between a separate function statement and the function object on the right side of =. In addition, IE even supports statements such as function String.prototype.test(){...}. It can be seen that IE's js has a lot of bugs. No wonder Wilson doesn't To support es4, we have to create es3.1, which is actually our own bug-fixed version.