H I O X INDIA
Javascript Tutorial
Google
Web hscripts.com
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java-Script Tutorial
Introduction
Variables
Operators
Statements
Loops
Functions
Objects
Arrays
Browser Objects
Form DOM
Ask Your Doubts
Feedback





Javascript Function


Topic

What is a function?
How to use functions in javascript?



Explanation

Function Tutorial:
        A function is nothing but a group or block of statements doing a specific task.

Syntax:
function name()
{
     // set of statements that will be executed
}


A function has to be defined in the above syntax.
The name "function" followed by the name we choose for the function and then open and close brackets. The statements that will do the specific operation are then group together under this name using braces.

A function may or may not return a value. A function may or may not have parameters value.

Invoking a function:
      The statements inside the function will not be executed automatically. We have to invoke or call the function to execute the statements. Just calling the name of the function will invoke the function. i.e. if we write a function with the name "test" calling it as "test();" will invoke the function.

Example Code:
<script language="javascript">
function test()
{
     document.write(" ---- This is a test function ---- ");
}

test();
</script>


Result:


        Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

others

privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Other Links