This article mainly introduces the JavaScript in the specified function name related methods, is the basic knowledge of JS learning, need friends can refer to the
JavaScript1.2 introduces the concept of function text as a new method of defining functions.
The function text is an expression that defines a nameless function.
Grammar
The syntax of a literal function is very similar to a function declaration, except that it is used as an expression, not as a declaration, a function name is required.
?
| 1 2 3 4 5 6 7 |
<script type= "Text/javascript" > <!--var variablename = function (Argument List) {function Body}; --> </script> |
In syntax, you can create a literal function for the specified function name:
?
| 1 2 3 4 5 6 7 |
<script type= "Text/javascript" > <!--var variablename = function functionname (Argument List) {function Body}; --> </script> |
But that doesn't make any sense, so it's not worth using.
Example:
Here is an example of creating such a function:
?
| 1 2 3 4 5 |
<script type= "Text/javascript" > <!--var func = function (x,y) {return x*y}; --> </script> |
You can call the following in the function above:
?
| 1 2 3 4 5 |
<script type= "Text/javascript" > <!--func (10,20); This would produce//--> </script> |