Home > front end >  DOM click event
DOM click event

Time:09-27

Help bosses when obtaining anonymous function is always display function definition that a wrong

CodePudding user response:

When the function keyword appears at the beginning (statement), it is a function declaration statement ", as a statement will not have a return value, so he has to write a function name,

When the function keyword is not appeared at the beginning (statement), it is a "function", as the expression returns a value, can be anonymous,

CodePudding user response:

Use parentheses to you 33 enclosed the function of life, if you need immediate execution, can put on the outside of the package function of parentheses a parentheses:
 
(function () {
Alert (" what, I got the point ")
}) ()

CodePudding user response:

Without the function name, you can add a function name, direct execution of the function name, or add a pair ()
  • Related