Famous and unknown functions in javascript

Source: Internet
Author: User

Example: 1
Copy codeThe Code is as follows:
Function (){
Alert ("I am my feet ");
}


2
Copy codeThe Code is as follows:
Var a = function (){
Alert ("I am my feet ");
}

The methods of 1 and 2 are equivalent. 1 is a famous function, while 2 is just to point a variable to an unknown function, and 1 and 2 are equivalent here. 2. You can add parentheses after the function declaration to call the function immediately after the creation. For example:
Var I = function (obj ){
Alert (obj );
} ("I am my feet ");
In addition, there is an important difference between a famous function and an unknown function: For a famous function, it can be defined after it is called. For an unknown function, it must be defined before it is called. For example, the following example shows an error when using an anonymous function:
I ();
Var I = function (){
Alert ("I am my feet ");
}
The following statements are correct:
Var I = function (){
Alert ("I am my feet ");
}
I ();
Or use the famous function:
I ();
Function I (){
Alert ("I am my feet ");
}

Related Article

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.