function expression
anonymous function var anonymous = function () {return true;};/ /named function var named = function named () {return true;} Iife functions immediately-invoked function Expression (function () { console.log (' hello! ');}) ();
Do not declare functions in a function block (if while etc), although the browser allows you to assign a variable to a function, but different browsers may parse differently.
ECMA-262 defines a block as a set of statements, but the function is not a statement.
Goodvar test; if (AAA) {test = function test () {console.log (' hi~~ ');};}
Badif (AAA) {function test () {Console.log ('??? ');}}
Do not name a parameter arguments, otherwise he will take precedence over the arguments object that is passed to each function scope.
Goodfunction aaa (Name,sexual,age) {}//badfunction bbb (name,sexual,arguments) {}
"Learning Notes" JavaScript coding specification-functions