The code information comes from http://ejohn.org/apps/learn/.
What can I use to declare a function?
return true varreturntruereturntrue;}; Console.log (isnimble, Canfly, isdeadly); // function isnimble () function canfly () function window.isdeadly ()
In this code, we declare the global function in three ways:
1.isNimble, using a named function.
2.canFly, declare an anonymous function, assign this function to a global variable (with VAR). Depending on the nature of the function, you can use the Canfly () call.
3.isDeadly, declare an anonymous function, assign this function to the property of the Window object isdeadly, you can call this function using window.isdeadly () and deadly ().
is the order of function declarations important?
var function return true functionreturntrue//truefunction return true; }
When a named function declaration is used, the function can be referenced at the current scope.
Where can I assign a reference?
typeof Canfly = = "undefined", "can not referto"typeof isdeadly = "undefined", "nor can"var functionreturntruefunctionreturntrue; };
You cannot use the Declare anonymous function when you assign it to a variable.
Can I declare a function under return?
function Stealthcheck () { Console.log (Stealth ()); // true return Stealth (); function return true ; } } stealthcheck ();
Sure enough, a function that uses a named declaration can be referenced anywhere in the current scope.
JavaScript Advanced Knowledge Analysis--defining functions