JavaScript function self-organizing

Source: Internet
Author: User

1.3 ways to define a function:

// The 1.function statement will only be interpreted once, and the following will overwrite the previous one, with precedence resolved function test1 () {    console.log (' test1 ');} Test1 (); // 2. The direct amount of the function will only be interpreted once, and the following will overwrite the previous, sequential parsing var test2=function() {    console.log (' test2 ');} Test2 (); // 3. Each time you perform a dynamic new var test3=New Function ("A", "B", "Return a+b;"); // top-level scopes, sequential parsing console.log (TEST3);

2. Parameters of the function:

functionFun (a,b,c,d) {console.log (fun.length);//number of formal parameters    //arguments object: can access the actual number of parameters, internal is an array, can only be used inside the function, often used for recursive operationConsole.log (arguments.length); Console.log (typeofarguments);    Console.log (arguments); //Arguments.callee points to the function itself (fun)    if(Arguments.callee.length = =arguments.length) {        returnA +b; }Else{Console.log (' Pass parameter Error! '); }}fun ((a);

JavaScript function self-organizing

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.