Ext JS Learning the third day we are familiar with JavaScript (ii)

Source: Internet
Author: User

function of JavaScript • For ext developers, I still hope that you will be able to understand and even skillfully use javascript native things. The function, then, is undoubtedly a very important concept. First of all, we know that a function is also a data type, and there are three ways to create a function. Each way they will be different: –function statement form – Function Direct Quantity form – constructor form • Function of arguments object –argument function One: Accept the function of the actual parameters of the role of –argument two: used to do the recursive Operation Chestnut Code
1 //function Functions2 //The main difference between the first two creation functions: The function statement, the JavaScript interpreter goes straight back, the other code executes from top to bottom .3 fun1 ();4 alert (fun2);5 fun2 ();6 //1:function Statement Form7 function fun1 () {8Alert'fun1 ...');9 };Ten //2: Form of the function direct quantity One varFun2 =function () { AAlert'fun2 ...'); - }; -  the //the third type of constructor, which has a scope that differs from the first two, has a top-level scope - //3: constructor function form - varFUN3 =NewFunction ('x','y','return x+y;'); -Alert (FUN3 (Ten, -)); +  -  +  A varK =1 ; at function Test () { -     varK =2 ; -     //to create a function of three different ways: -     //function f () {return k;}; -     //var f = function () {return k;}; -     varf =NewFunction ('return k;'); in alert (f ()); - }; to test (); +  -  the  * //arguments object: There is a arguments object inside each function $ function Test (x, y) {Panax Notoginseng     //First function: Accept the actual parameters of a function -alert (arguments.length);//len = 3 theAlert (arguments[2]);//val = 3 + }; ATest1,2,3); the  + //second effect: typically used for recursive operations - //Arguments.callee indicates that the current function itself is referenced $ function Fact (number) { $     if(Number <=1){ -         return 1 ; -}Else { the         returnNumber*arguments.callee (number-1); -     }Wuyi }; the //Alert (Fact (5)); - varFact2 =fact; WuFact =NULL ; -Alert (Fact2 (5));

Recommended to you a beautiful article network www.fishcmonkey.com, learning to improve literary accomplishment

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.