Function
There is a certain function of the code body of the collection, the basic structure:
function functionname () {Execute code}
Base function, invocation:
function Hanshu () {alert " this is the first function "}
Hanshu (); function call
Category: Functions with Parameters:
function Hanshu (a) {alert A}//A is a formal parameter, formal argument.
Hanshu (b)//b is an argument, the actual parameter. function Hanshu sum (A, B) {alert (a+b)} sum (2,3)//parameters are assigned when called,
function with return value
function sum (A, B)
{
return a+b;
}
SUM (10,5);//program After executing this sentence, sum (10,5) becomes 15;
var c=sum (10,5);
alert (c); *///c is 15.
Global variables: var carname = "Volvo";
The Carname variable can be called here
function MyFunction () {
Carname variables can be called within a function
}
Local variables:
The Carname variable can be called here
function MyFunction () {
Carname = "Volvo";
The Carname variable can be called here
}
Functions of the Java Script Foundation