Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
All Statements
STATEMENT: function
function
name([param] [, param] [..., param]) {statements}
The
function
statement declares a function with its specified parameters, which can include numbers, strings and objects. To return a value, a function must have a
return
statement specifying the value to return.
The word, function, is a reserved word. You cannot name a function, "function". Rather, use a word, or blend of words, that describe the purpose that the function performs.
The following code declares a function that calculates the average of three numbers and returns the result:
Code:
function calcaverage(a, b, c)
{
return (a+b+c)/3;
}
document.write(calcaverage(2, 4, 6));
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information