Amazon Purchase Links:
*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
- Easy to write a program:
- Easy to understand and modify the program:
The complexity of the program is reduced. It makes easier to understand the logic of the program. It is also easy to make changes and detect errors when large program is divided into subprograms.
- Eliminate duplicate code:
- Facilitate re-usability:
- Built-in functions
- User-defined functions
- In the <head> section of html document.
- In the <body> section of html document.
The first line of function definition is called function header. It is also referred to as function declarator. It indicates the start of function definition.
The general syntax to define the function is as follows:
function fname(parameter list)
Body of the function;
document.write(“First Function”+ “<br>”);
Similarly if a function returns a value then it can be called in an arithmetic expression, or can directly be called in an output statement.
document.write("Examples of Scripting Languages are: "+ "<br>");
document.write("script is terminated");
var u ,i;
for (u=9; u>=1;u-=2)