The difference between the parentheses and the name of the write function when JS calls the function the difference between FN and FN ()

Source: Internet
Author: User

Often see the plug-in inside the function call only write a function name, do not write function parameters, and even parentheses do not write, for example, said:

1 <!DOCTYPE HTML>2 <HTML>3     <Head>4         <MetaCharSet= "Utf-8" />5         <title></title>6         <Scripttype= "Text/javascript">7             functionA1 () {8 Alert ('a');9                 return '1';Ten             }; One              A          - window.onload=function(){ -              the             //no parentheses represent all parts of the function, - alert (A1); -              - Alert ('A1 End'); +              - //the parentheses represent the part of the function body. + alert (A1 ());  A         } at                  -                  -         </Script> -     </Head> -     <Body> -     </Body> in </HTML>

The results shown above are as follows:

Can be seen,

1. write only the function name is equivalent to taking all parts of the function, including the declaration:

Example: BTN.ONCLICK=A1

Equivalent to

Btn.onclick=function A1 () {

Alert (' a ');
Return ' 1 ';

}

2. Writing the function brackets represents the calling function, similar to a function call in Java.

The difference between the parentheses and the name of the write function when JS calls the function the difference between FN and FN ()

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.