1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "UTF-8">5 <title></title>6 </Head>7 <Body>8 </Body>9 <Scripttype= "Text/javascript">Ten //function: a function block One //Syntax: function name (argument list) {function Body} A //function use is divided into two parts: 1, function definition 2, function invocation - //1. No parameter function - functionmyFunction () { the Alert ("I am a non-parametric function"); - } - myFunction (); - + - //2. Function with Parameters + functionArgsfunction (A, b) { A if(A>b) { at Alert ("a>b"); - }Else{ - Alert ("a<b"); - } - } - Argsfunction (3,1); in - to //3, the function form parameter does not fill the processing situation + functionMyfunction2 () { - var First=arguments[0]; the varSecond=arguments[1]; * alert (first); $ alert (second);Panax Notoginseng }myfunction2 (3,Ten); - the + A //4. Functions that do not write function names (anonymous functions)---widely used the function (){ + Alert ("1"); - } $ $ - //5, with the return value of the function, to find two numbers of the and, a function - A , within its function body can only have areturn the B, the statement after return no longer executes - functionMyFunction3 (A, b) {Wuyi varresult=a+b; the returnresult; - Alert ("how you doing?"); Wu } - About $ - //6, define a variable to accept the return value of the function - - functionMyFunction3 (A, b) { A varresult=a+b; + returnresult; the } - $ varTemp=MyFunction3 (3, -); the alert (temp); the the the - in //simplification of code the functionMyFunction3 (A, b) { the //var result = a + B; About //return result; the returna+b; the } the //defines the return value of a variable-accept function + //var temp = MyFunction3 (3,20); - //alert (temp); the alert (MyFunction3 (3, -));Bayi the the - </Script> - </HTML>
JS Debug Statement