JavaScript Function
A function is a separate part of the program that performs a particular task. The code of the function can be reused by calling the same function wherever it is required to perform the same task.
A function syntax is as the keyword function followed by function name, followed by a list of parameters and a statement block in curly brackets.
example:
function fun(parameter1,parameter2){
.
statement 1;
statement 2;
.
.
statement n;
}
Here, in the above example fun is the name of the function and parameter1, parameter2 are the parameters list.
The parameters of the function receives the values to work on.
The body of the function contains statement 1,statement 2 . . . statement n covered under curly brackets.
0 Comment(s)