Java Script function
definition; a function is an event-driven or reusable block of code that executes when it is invoked.
Basic format; Functionname (formal parameter) {code block}. Call function----------function name (argument);
Knowledge point; 1. The parameters that are accepted by the function are controlled by the actual parameter;
column; function stt (x, y) {return arguments.length;}
document.write (STT (1,2,3,4));
The result is 4.
2. when the formal parameter has a default value and there is no incoming parameter, the function accepts the parameter as the default value of the formal parameter. Arguments that are accepted when an argument is passed in are arguments.
function STT (x=1,y=2) {return x+y; }
document.write (STT ());
The result is 3;
document.write (STT (3,4));
The result is 7;
Explanation: Arguments is an array of system writes, and window is an object that gets global.
Java Script function