JavaScript 1.2 introduces the concept of function literals as a new way to define more than one function.
A function literal is an expression that defines an unnamed 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, and the function name is required.
<script type="text/javascript"> <!-- var variablename = function(Argument List){ Function Body }; //--> </script>
Syntactically, you can create a literal function by specifying the function name:
<script type="text/javascript"> <!-- var variablename = function FunctionName(Argument List){ Function Body }; //--> </script>
However, the name means nothing, so it's not worth using it.
Example:
Here is an example of creating such a function:
<script type="text/javascript"> <!-- var func = function(x,y){ return x*y }; //--> </script>
You can call the following function in the above function:
<script type="text/javascript"> <!-- func(10,20); // This will produce 200 //--> </script>