js basis functions

function

1, a plurality of arbitrary function can encapsulate the code, a code block is formed

2, the role of function

                    Code reuse

3, function declarations

                  Keywords: function

4, function declarations

                function name of the function () {}

5, function expression

                var func = function [function name] () {}

Anonymous function

             function(){

                }

Function declarations (recommended)

               function   change(){

                 }

Function expression

                 var   change    =   function (){

                }

6, function calls

              After defining function does not execute code function must be called to perform the function.

  

     Direct call: function name ();

     Event trigger a call: The function assigned to the event

7, an anonymous function

              After you define an anonymous function to be executed immediately, otherwise it will error

8 Notes

             To comply with the function name variable naming rules.

Guess you like

Origin blog.csdn.net/quxiaojiao_39/article/details/89761461