Related methods for specifying function names in JavaScript

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.