<! DOCTYPE html>
<meta charset= "Utf-8" >
<title></title>
<body>
<script type-"Text/javascript" >
The first chapter, the Custom function.
test ();
function Test () {
Alert (' This is a test ');
}
Test ();
Function names are strictly case-sensitive
function TEST () {
Alert ("Hello King");
}
TEST ();
Duplicate function name will result in overwrite
Test ();
function Test () {
Alert (' Hello Maizi ');
}
Test ();
function Test1 () {
Alert (' This is test1 function ');
}
Alert (test1 ());
function Test2 () {
return null;
return undefined;
Return
return true;
Return ' This is king ';
return 1.2;
Alert (' This is a test ');
return 1;
}
alert (test2 ());
The function returns the value by return and returns the undefined if no return is returned by default
Function names do not contain special characters
Function names are best followed by hump notation or underline notation
Functions can have parameters or can have no parameters, can have one argument or can have multiple parameters
function expressions can be stored in variables, and variables can also be used as a function
Anonymous functions can be passed as arguments to other functions, and the receiving function can perform certain functions by passing in functions
You can perform some one-time tasks through anonymous functions
Function Calc (num1,num2) {
return num1+num2;
}
Alert (calc);
The third chapter calls the function.
Called through the window. function name ()
alert (Window.calc (2,3))
Chapter three parameters.
JS ignores extraneous parameters when passing parameters that exceed the defined parameters when invoking a function
Alert (Calc (1,2,3,4,5,6,7,8,9))
Parameters (Arameter)
JS cannot directly write default values, you can use the arguments object to achieve the default value effect
function Calc1 (num1,num2) {
num1=num1| | 1;
num2=num2| | 2;
return num1+num2;
}
Alert (Calc1 (3,5));
</script>
</body>
Java Script The 11th lesson in Java script in the functions-through function key